This seems too easy and obvious, but I cannot find out how to test the following:
My Java method:
public void doSth(final Foo foo) {
assert foo != null;
..
}
My test:
@Test
public void testAssertion() {
doSth();
doSth(new Foo());
}
I can test quite many things with assertEquals
etc., but how to create a test case that gives true if that assert there on foo != null;
gives negative?
The test I have now goes on green in both cases of assertion, but I cannot catch the assertion fails or not.
I want my code test coverage to 100% and would like to test something meaningful on this line.