JUnitUseExpected

This rule is defined by the following Java class: net.sourceforge.pmd.rules.migration.JUnitUseExpected

Example:

                

public class MyTest {
	@Test
    public void testBad() {
        try {
            doSomething();
            fail("should have thrown an exception");
        } catch (Exception e) {
        }
    }

	@Test(expected=Exception.class)
    public void testGood() {
        doSomething();
    }
}