Java Code Examples for org.junit.jupiter.api.Assertions#expectThrows()
The following examples show how to use
org.junit.jupiter.api.Assertions#expectThrows() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MD5DigesterTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
/** * Method: update(String value) */ @DisplayName("update(String value) with exception") @Test public void testUpdateString_withException() throws Exception { String value = "abc123"; MessageDigest mockMessageDigest = mock(MessageDigest.class); doThrow(UnsupportedEncodingException.class).when(mockMessageDigest) .update(any(byte[].class)); md5Digester.setMessageDigest(mockMessageDigest); Assertions.expectThrows(P4JavaError.class, () -> md5Digester.update(value)); }
Example 2
Source File: MD5DigesterTest.java From p4ic4idea with Apache License 2.0 | 5 votes |
/** * Method: update(String value) */ @DisplayName("update(String value) with exception") @Test public void testUpdateString_withException() throws Exception { String value = "abc123"; MessageDigest mockMessageDigest = mock(MessageDigest.class); doThrow(UnsupportedEncodingException.class).when(mockMessageDigest) .update(any(byte[].class)); md5Digester.setMessageDigest(mockMessageDigest); Assertions.expectThrows(P4JavaError.class, () -> md5Digester.update(value)); }