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 java.lang.Object implements org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.TestExecutionExceptionHandler
ThisExtension
provides native support for theExpectedException
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)
,ExpectedException
,TestRule
,Rule
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
EXCEPTION_WAS_HANDLED
private TestRuleSupport
support
-
Constructor Summary
Constructors Constructor Description ExpectedExceptionSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterEach(org.junit.jupiter.api.extension.ExtensionContext context)
private org.junit.jupiter.api.extension.ExtensionContext.Store
getStore(org.junit.jupiter.api.extension.ExtensionContext context)
void
handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Throwable throwable)
-
-
-
Field Detail
-
EXCEPTION_WAS_HANDLED
private static final java.lang.String EXCEPTION_WAS_HANDLED
- See Also:
- Constant Field Values
-
support
private final TestRuleSupport support
-
-
Method Detail
-
handleTestExecutionException
public void handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, java.lang.Throwable throwable) throws java.lang.Throwable
- Specified by:
handleTestExecutionException
in interfaceorg.junit.jupiter.api.extension.TestExecutionExceptionHandler
- Throws:
java.lang.Throwable
-
afterEach
public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws java.lang.Exception
- Specified by:
afterEach
in interfaceorg.junit.jupiter.api.extension.AfterEachCallback
- Throws:
java.lang.Exception
-
getStore
private org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context)
-
-