Sunday, July 11, 2010

Idea: JUnit and Code coverage connection

I'm going to share my first thoughts regarding unit testing, JUnit and TDD (test-driven development). I'm sure that this won't be the last post on this subject because there is a lot that can be said and I've had a few interesting discussions with a colleagues of mine regarding the benefit of TDD and whether it is a good or a bad principle.

---

Here I'm going to share a thought which seems logic to me, but unfortunately have not seen it implemented yet.
I've been writing some unit tests recently and  it occurred to me that it would be nice if the JUnit was combined with code coverage and after runs of the test suites, there is a statistic that shows which test (test method), which lines of code did they cover!

Imagine if it was possible to see that - when an old test fails, it shows you which particular code it validates, so if a change in that code occurred, you can catch it immediately!

Of course there is the scenario when a change occurred in the context of the process that is tested and not the process itself and the code that could break a certain test, but nevertheless this information won't lie to you and trick you and slow you down in rooting down the real problem.

Also some monitoring of the submits to the project repository and analyzing which code fixes what test , would be the same as which test validates which lines of code.

There could be done something about that!


----
Some basic tips:

For NetBeans users check this link:
http://netbeans.org/kb/docs/java/junit-intro.html

Check official xUnit site or Junit
http://www.junit.org/

L.K. 

No comments:

Post a Comment