Before this question is marked as a duplicate, read it .;) There are already several questions about the means of coverage, etc., but this is slightly different from the usual ones (I hope).
According to wikipedia, there are several different options for βreachβ that affect several different aspects of the term βreachβ.
Here is a small example:
public class Dummy { public int a = 0; public int b = 0; public int c = 0; public void doSomething() { a += 5; b += 5; c = b + 5; } } public class DummyTest { @Test public void testDoSomething() { Dummy dummy = new Dummy(); dummy.doSomething(); assertEquals( 10, dummy.c ); } }
As you can see, the test will have coverage of 100% of the lines, the statement about the value of the field βcβ will cover this field and indirectly also cover the field βbβ, however there is no coverage of the statement in the field βaβ. This means that the test covers 100% of the lines of code and ensures that c contains the expected value and most likely also contains b, contains the correct one, however a is not approved at all and may have a completely incorrect value.
So, now the question is: is there a tool that can analyze (java) code and create a report about which fields / variables / everything that was not (directly and / or indirectly) covered by the statement?
(ok when using getters instead of public fields, you will see that getA () is not being called, but this is not the answer I would like to hear;))
Danilo tommasina
source share