Details
Recommendation type: No assertions
Configurable: Yes
Filter category: Assertions
Description
JUnit tests should include at least one assertion. Using a message for each assertion makes the reason for failure more clear and makes the test easier to maintain and debug.
Example
...
Code Block |
---|
public class Foo extends TestCase { public void testSomething() { Bar b = findBar(); // This is better than having a NullPointerException // assertNotNull("bar not found", b); b.work(); } } |
...