- Making metamorphic testing report look better
-
Please don’t forget including fragment in your test class, which customize the report generation Metamorphic Testing feature of
valid8j
.
@BeforeClass
public static void beforeAll() {
Validator.reconfigure(b -> b.reportComposer(new MetamorphicReportComposer()));
}
assert{All,Statement}
orassume{All,Statement}
give non-informative error message-
If you see a message like following:
Exception in thread "main" org.opentest4j.AssertionFailedError: Value:100 violated: (>=[0]&&<[100]) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.github.dakusui.valid8j.pcond.validator.ExceptionComposer$ForTestAssertion$Opentest4J.lambda$testFailedException$1(ExceptionComposer.java:264)
It is pretty much because you don’t have ComparisonFailure
class on your classpath, which is frequently caused by running your test in the production code.
Move your methods to the test code side.
References
-
[1] Wikipedia article on Design by Contract, Design by contract
-
[2] valid4j valid4j.org
-
[3] pcond dakusui.github.io/pcond
-
[4] Valid4j, valid4j.org
-
[5] PreconditionsExplained, PreconditionsExplained
-
[6] Hamcrest hamcrest.org
-
[7] Programming With Assertions Programming With Assertions
-
[8] Preconditions, Google Guava Preconditions class
-
[9] Validates, Apache Commons Validate class