Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space ENGINES1031 and version 10.4.0

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

...