Write the test first….. Then code to make your test pass
JUnit is a unit testing framework for the Java programming language . JUnit has been important in the development of test-driven development , and is one of a family of unit testing frameworks collectively known as xUnit that originated with SUnit .
Code coverage is a measure used in software testing . It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing .
Think about how you can focus around the developer and how Code Coverage can be used with Unit Testing.
If you ask most developers if they do a good job testing their code, they would tell you yes.
However in another study (Boris Beizer in Johnson 1994), the average programmer thought they tested around 95 percent of the code they wrote, but on further inspection the amount of actual code was more like 30 percent.
This information can be very enlightening. Think about it... you exercise your application with Code Coverage turned on and the results come back as 35 percent coverage. What's the deal? Did you just run your application with the "happy path" only or did you truly exercise the application? If you did exercise the application, then it appears a great deal of code may not be needed.
For example, say that starting on week one we had 40 percent total coverage with unit test, week two we had 50 percent of coverage with unit tests, and week three we had 30 percent coverage with unit tests… what gives?
Well from week three to four it may have been that the amount of code stayed about the same and more unit tests were created, and between weeks four and five a lot of code was added and very few unit tests were added.
EclEmma is a free Java code coverage tool for Eclipse, available under the Eclipse Public License. Internally it is based on the great EMMA Java code coverage tool, trying to adopt EMMA's philosophy for the Eclipse workbench:
Fast develop/test cycle: Launches from within the workbench like JUnit test runs can directly be analyzed for code coverage.