Class JUnitUseExpectedRule

  • All Implemented Interfaces:
    JavaParserVisitor, ImmutableLanguage, PropertySource, Rule

    public class JUnitUseExpectedRule
    extends AbstractJUnitRule
    This rule finds code like this:
     public void testFoo() {
         try {
             doSomething();
             fail("should have thrown an exception");
         } catch (Exception e) {
         }
     }
     
    In JUnit 4, use
      @Test(expected = Exception.class)
     
    Author:
    acaplan