Asserts are not found in other methods
A source code analyzer
Brought to you by:
adangel,
juansotuyo
This rule net.sourceforge.pmd.rules.junit.JUnitTestsShouldContainAsserts
The rule complains there are no "asserts" found in a test method.
The asserts are actually in separate helper methods.
I do this when I have a common set of assertions. I put them into a helper method. Then I have the test methods call that helper method.
e.g.
@Test
public void testSomeStrings() {
testSomeString("test1");
testSomeString("test2");
testSomeString("test3");
}
private void testSomeString(String str) {
Assert.assertNotNull("The string was null.", str);
}