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)
  • ExpectedException
  • TestRule
  • Rule
  • Field Details

  • Constructor Details

    • ExpectedExceptionSupport

      public ExpectedExceptionSupport()
  • Method Details

    • handleTestExecutionException

      public void handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext context, Throwable throwable) throws Throwable
      Specified by:
      handleTestExecutionException in interface org.junit.jupiter.api.extension.TestExecutionExceptionHandler
      Throws:
      Throwable
    • afterEach

      public void afterEach(org.junit.jupiter.api.extension.ExtensionContext context) throws Exception
      Specified by:
      afterEach in interface org.junit.jupiter.api.extension.AfterEachCallback
      Throws:
      Exception
    • getStore

      private org.junit.jupiter.api.extension.ExtensionContext.Store getStore(org.junit.jupiter.api.extension.ExtensionContext context)