
public final class TestUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
TestUtils.MethodToCall
Functional Interface for
expectException(MethodToCall, Class). |
| Modifier and Type | Method and Description |
|---|---|
static Exception |
expectException(TestUtils.MethodToCall call) |
static <T extends Exception> |
expectException(TestUtils.MethodToCall call,
Class<T> expectedExceptionType)
Test the Exception-Case of your Logic.
|
static boolean |
isDefaultConstructorHidden(Class<?> clazz)
check if the Default constructor is hidden, and call it one time for Testcoverage Report :D .
|
public static Exception expectException(TestUtils.MethodToCall call)
call - The Method to testexpectException(MethodToCall, Exception.class).public static <T extends Exception> T expectException(TestUtils.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 - .public static boolean isDefaultConstructorHidden(Class<?> clazz)
check if the Default constructor is hidden, and call it one time for Testcoverage Report :D .
Usage: Assert.assertTrue(ClassUtils.isDefaultConstructorHidden(XyzUtils.class));
clazz - The Class to Test.Copyright © 2016–2019 Brabenetz Harald, Austria. All rights reserved.