Top Description Fields Constructors Methods
org.junit.jupiter.migrationsupport.rules

public Class ExpectedExceptionSupport

extends Object
implements AfterEachCallback, TestExecutionExceptionHandler
Class Inheritance
All Implemented Interfaces
org.junit.jupiter.api.extension.TestExecutionExceptionHandler, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.AfterEachCallback
Annotations
@SuppressWarnings:removal
@API
status:DEPRECATED
since:6.0
@Deprecated
since:6.0
forRemoval:true
Static Imports
org.apiguardian.api.API.Status.DEPRECATED

Deprecated

for removal since 6.0.

Please use org.junit.jupiter.api.Assertions#assertThrows(Class, Executable) instead.

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 org.junit.jupiter.api.Assertions#assertThrows for new code.

Since
5.0
See Also
org.junit.jupiter.api.Assertions#assertThrows, org.junit.rules.ExpectedException, org.junit.rules.TestRule, org.junit.Rule

Field Summary

Modifier and TypeField and Description
private static final String
private final TestRuleSupport

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterEach(ExtensionContext context)

Implements org.junit.jupiter.api.extension.AfterEachCallback.afterEach.

Callback that is invoked after an individual test and any user-defined teardown methods for that test have been executed.

private ExtensionContext.Store
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EXCEPTION_WAS_HANDLEDback to summary
private static final String EXCEPTION_WAS_HANDLED
supportback to summary
private final TestRuleSupport support

Constructor Detail

ExpectedExceptionSupportback to summary
public ExpectedExceptionSupport()

Method Detail

afterEachback to summary
public void afterEach(ExtensionContext context) throws Exception

Implements org.junit.jupiter.api.extension.AfterEachCallback.afterEach.

Doc from org.junit.jupiter.api.extension.AfterEachCallback.afterEach.

Callback that is invoked after an individual test and any user-defined teardown methods for that test have been executed.

Annotations
@Override
getStoreback to summary
private ExtensionContext.Store getStore(ExtensionContext context)
handleTestExecutionExceptionback to summary
public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable

Implements org.junit.jupiter.api.extension.TestExecutionExceptionHandler.handleTestExecutionException.

Doc from org.junit.jupiter.api.extension.TestExecutionExceptionHandler.handleTestExecutionException.

Handle the supplied throwable.

Implementors must perform one of the following.

  1. Swallow the supplied throwable, thereby preventing propagation.
  2. Rethrow the supplied throwable as is.
  3. Throw a new exception, potentially wrapping the supplied throwable.

If the supplied throwable is swallowed, subsequent TestExecutionExceptionHandlers will not be invoked; otherwise, the next registered TestExecutionExceptionHandler (if there is one) will be invoked with any Throwable thrown by this handler.

Note that the execution exception in the supplied ExtensionContext will not contain the Throwable thrown during invocation of the corresponding @Test method.

Annotations
@Override