A test case without assertions ensures only that no exceptions are thrown. Beyond basic runnability, it ensures nothing about the behavior of the code under test.
This rule raises an exception when no assertions are found in a JUnit test.
@Test
public void testDoSomething() { // Noncompliant
MyClass myClass = new MyClass();
myClass.doSomething();
assertThat(myClass.doSomething()); // Fest assertion stub with no checks
}
@Test
public void testDoSomething() {
MyClass myClass = new MyClass();
assertNull(myClass.doSomething()); // JUnit assertion
assertThat(myClass.doSomething()).isNull(); // Fest assertion
}