Is there a tool for Java which finds which lines of code are tested by specific JUnit tests?

There's an open source mutation-testing tool called Jester that changes the lines of your source code, then runs your tests, and reports whether your tests passed anyway. Sounds closer to what you're looking for than code coverage tools.

There's an open source mutation-testing tool called Jester that changes the lines of your source code, then runs your tests, and reports whether your tests passed anyway. Sounds closer to what you're looking for than code coverage tools. Jester is a test tester for testing your java JUnit tests (Pester is for Python PyUnit tests).

It modifies your source code, runs the tests and reports if the tests pass despite the changes to the code. This can indicate missing tests or redundant code. WRT the discussion about whether these tools are needed in a pure TDD project, there is a link on the Jester project webpage to a posting about the benefits of using Jester on code written during a TDD session (Uncle Bob's infamous bowling TDD example).

What you are looking for might be referred to as mutation testing. While mutation testing won't tell you which lines of code are required to pass, per se. What mutation testing does is modify your source code looking for changes it can make to your code but your test still passes.E.g.

Changing if (a = b) and seeing if the test still passes. This will highlight weaknesses in your test. Another java library for mutation testing is jumble.

I love cobertura, because the generated reports are IMHO the most beautiful. And it has its own ant target! In comparison to emma, it has also branch coverage, not only line coverage, which is misleading very often.

1 IMO cobertura is the best solution to this problem – bwawok Sep 9 '10 at 14:46 Cobertura is great for code coverage, but I think the OP is looking for assertion coverage. E.g. You can have 100% code coverage, but assert nothing.

The OP is looking for a tool to help identify where assertions are lacking. – Chris Knight Sep 9 '10 at 14:55.

I use emma for most of my projects. I included it in my ant build file and it generates html files for the reports two other coverage projects I read about but haven't tried yet are clover or cobertura.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions