Is there any 'assertion' coverage tool (for Java)?

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

+7
source share
4 answers

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.

Well, the β€œcover”, unfortunately, means different things to different people ... This test really does 100% of the lines of code, but it does not test them all.

What you are looking for is well handled by mutation testing .

Check out Jester , who uses mutation testing to report code coverage.

+2
source

There are hundreds of definitions of β€œtest coverage,” of which only a few at the best of COTS tools. (My company builds testing tools, so we track such things). See this test coverage lecture for an interesting overview.

The closest definition I've heard is one for covering data; depending on your definition: - {it tells you that each data item was written and read at runtime. The lecture talks about verifying that each record and each reading is performed as a special case.

I don’t know by heart hundreds of names, but you may have invented one more thing: data coverage is limited to statements.

+1
source

follow this link below

Compatibility Checker

0
source

There are Assertions in Java if that is what you are looking for.

To find out how much code has been reviewed, there are tools you can use here: cobertura clover

0
source

All Articles