Class JUnitUseExpectedRule

  • All Implemented Interfaces:
    net.sourceforge.pmd.lang.ast.AstVisitor, JavaVisitor, net.sourceforge.pmd.lang.rule.Rule, net.sourceforge.pmd.properties.PropertySource

    public class JUnitUseExpectedRule
    extends AbstractJavaRulechainRule
    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