public final class TestUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
TestUtil.MethodToCall
Functional Interface for
expectException(MethodToCall, Class). |
| Constructor and Description |
|---|
TestUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Exception |
expectException(TestUtil.MethodToCall call) |
static <T extends Exception> |
expectException(TestUtil.MethodToCall call,
Class<T> expectedExceptionType)
Test the Exception-Case of your Logic.
|
public static Exception expectException(TestUtil.MethodToCall call)
call - The Method to testexpectException(MethodToCall, Class)public static <T extends Exception> T expectException(TestUtil.MethodToCall call, Class<T> expectedExceptionType)
Example Usage:
MyException expectedException = TestUtils.expectException(() -> myService.myMethodToTest(), MyException.class);
assertThat(expectedException.getMessage(), containsString("..."));
T - The type of the expected Exception.call - The Method to testexpectedExceptionType - .Copyright © 2017 Glasnost. All Rights Reserved.