T
- The exception typepublic interface AssertThatException<T extends Throwable>
This interface is returned by the various methods
assertWhen
exposed by
TestSuite
.
Modifier and Type | Method and Description |
---|---|
boolean |
throwException(Matcher<? super T> matching)
Define the matcher on the exception and execute the matcher validation.
|
boolean throwException(Matcher<? super T> matching)
By default, assertion can only be used from the main thread of the
test ; When used from another thread, the assertion will be lost. In the
case the fastFail
attribute of @Test
annotation is used, the assertion may not be lost, in case the thread use
an assertion method from the test object instance.
For instance, having this method :
public static void method1() throws Exception { throw new Exception("demo1"); }It is possible to test the message by using :
assertWhen(asStatement(DemoAssertThatExceptionTest::method1)).throwException( exceptionMessage("demo1"));
matching
- the matcher.Test.fastFail()
: If true
, then
fail the test, else, return false and the test will be failed
later.The documentation of the fastFail
attribute of the @Test
annotation, regarding the action
done by this assertion.
Copyright © 2015 Powerunit. All rights reserved.