Having the test case using JUnit 4.12:
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
//...
@Test
public void testShouldReturnNull() {
final Long result = getIdFunction.apply(null);
assertThat(result, is(nullValue()));
}
Sonar says:
Add at least one assertion to this test case.
Why does Sonar says that there are no assertions and how it can be fixed?
SonarQube v6.7
I've just found a solution for this case:
Here should be used assertThat method from Hamcrest's MatcherAssert class instead of JUnit's Assert class. So here should be used next import:
instead of: