Wednesday, October 1, 2008

Still get a bug with 100% line coverage

On my previous blog “Using Emma for code coverage,” I used Emma as my code coverage tool in a program that I am working on. You can also use google.com (or another search engine) about code coverage if you want to learn more about it. Code coverage is the measure of a program code. It is a form of testing that looks at the code directly and measure if a line is being use by the program. So I am at 100% code coverage in my program.


So the test that I am going to do is to write some more code into my program and make it crash but still get 100% code coverage with Emma. An excellent idea created by Professor Philip Johnson is to have a static Array List of ten elements. Using that array list and “break” the array list by going over the limit (which is 10). So I done that went over the limit by 1000000. When I run the program it contains the bug, but Emma still gives my program 100% code coverage.


Like I said in my previous blog “Using Emma for code coverage,” using Emma is great; it saves time in debugging. What I learn from using a code coverage tool like Emma is that it does not show all the bugs in the code. For example input and output of results, Emma say the program have 100% coverage, but the program can crash if it is not correctly use. What I like to say is that code coverage tool is like a thin protection, but it does not expose all the flaws in a program.

In my program, Emma stated that it have 100% coverage, but there is a bug in it that it does not know unless the program is run. The best solution is to know what inputs are going to use and what outputs that are going to be generated. Knowing those then you will have a program that satisfy what you want it to do and no bugs.
Here is the .ZIP containing the source and build files: http://sites.google.com/site/phillipkhlau/files/stack-JUnit-Lab-klau4-6.0.1001.zip

No comments: