All Downloads are FREE. Search and download functionalities are using the official Maven repository.

resources.report.rules.pmd.JUnitUseExpected.html Maven / Gradle / Ivy



JUnitUseExpected

JUnitUseExpected

In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.

This rule is defined by the following Java class: net.sourceforge.pmd.lang.java.rule.migrating.JUnitUseExpectedRule

Example(s):


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();
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy