Class ExpectedExceptionToAssertThrows

java.lang.Object
org.openrewrite.Recipe
org.openrewrite.java.testing.junit5.ExpectedExceptionToAssertThrows

public class ExpectedExceptionToAssertThrows extends org.openrewrite.Recipe
Replace usages of JUnit 4's @Rule ExpectedException with JUnit 5 Assertions.

Supported ExpectedException methods: expect(java.lang.Class) expect(org.hamcrest.Matcher) expectMessage(java.lang.String) expectMessage(org.hamcrest.Matcher) expectCause(org.hamcrest.Matcher)

Does not currently support migration of ExpectedException.isAnyExceptionExpected().

  • Constructor Details

    • ExpectedExceptionToAssertThrows

      public ExpectedExceptionToAssertThrows()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in class org.openrewrite.Recipe
    • getEstimatedEffortPerOccurrence

      public Duration getEstimatedEffortPerOccurrence()
      Overrides:
      getEstimatedEffortPerOccurrence in class org.openrewrite.Recipe
    • getDescription

      public String getDescription()
      Overrides:
      getDescription in class org.openrewrite.Recipe
    • getSingleSourceApplicableTest

      protected org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getSingleSourceApplicableTest()
      Overrides:
      getSingleSourceApplicableTest in class org.openrewrite.Recipe
    • getVisitor

      protected org.openrewrite.TreeVisitor<?,org.openrewrite.ExecutionContext> getVisitor()
      Overrides:
      getVisitor in class org.openrewrite.Recipe