Package stack.source.junit5
Class ErrorDecorator
java.lang.Object
stack.source.junit5.ErrorDecorator
- All Implemented Interfaces:
org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.TestExecutionExceptionHandler
@AutoService(org.junit.jupiter.api.extension.Extension.class)
public final class ErrorDecorator
extends java.lang.Object
implements org.junit.jupiter.api.extension.TestExecutionExceptionHandler
Decorates stack traces with source code snippets.
Example output:
org.junit.ComparisonFailure: expected:<H[ello]!> but was:<H[i]!>
at org.junit.Assert.assertEquals(Assert.java:115)
at example.HelloTest.hello(HelloTest.java:16)
14 @Test
15 public void hello() {
-> 16 assertEquals("Hello!", greet());
17 }
...
Usage:
@ExtendWith(ErrorDecorator.class)
class BaseTest {}
class MyTest extends BaseTest {
@Test
void myTest() {
// ...
}
}
Alternatively, run your tests with
-Djunit.jupiter.extensions.autodetection.enabled=true
instead of using annotations.
-
Constructor Summary
Constructors Constructor Description ErrorDecorator() -
Method Summary
Modifier and Type Method Description voidhandleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Throwable e)
-
Constructor Details
-
ErrorDecorator
public ErrorDecorator()
-
-
Method Details
-
handleTestExecutionException
public void handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Throwable e) throws java.lang.Throwable- Specified by:
handleTestExecutionExceptionin interfaceorg.junit.jupiter.api.extension.TestExecutionExceptionHandler- Throws:
java.lang.Throwable
-