Class ExpectedExceptionSupport
java.lang.Object
org.junit.jupiter.migrationsupport.rules.ExpectedExceptionSupport
- All Implemented Interfaces:
org.junit.jupiter.api.extension.AfterEachCallback,org.junit.jupiter.api.extension.Extension,org.junit.jupiter.api.extension.TestExecutionExceptionHandler
@API(status=STABLE,
since="5.7")
public class ExpectedExceptionSupport
extends Object
implements org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.TestExecutionExceptionHandler
This
Extension provides native support for the
ExpectedException rule from JUnit 4.
By using this class-level extension on a test class,
ExpectedException can continue to be used.
However, you should rather switch to
Assertions.assertThrows(java.lang.Class<T>, org.junit.jupiter.api.function.Executable) for new code.
- Since:
- 5.0
- See Also:
-
Assertions.assertThrows(java.lang.Class<T>, org.junit.jupiter.api.function.Executable)ExpectedExceptionTestRuleRule
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterEach(org.junit.jupiter.api.extension.ExtensionContext context) voidhandleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable throwable)
-
Constructor Details
-
ExpectedExceptionSupport
public ExpectedExceptionSupport()
-
-
Method Details
-
handleTestExecutionException
public void handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable throwable) throws Throwable - Specified by:
handleTestExecutionExceptionin interfaceorg.junit.jupiter.api.extension.TestExecutionExceptionHandler- Throws:
Throwable
-
afterEach
- Specified by:
afterEachin interfaceorg.junit.jupiter.api.extension.AfterEachCallback- Throws:
Exception
-