InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Cobertura Only Writes The Coverage Data File When The Application Server Shuts Down. We Do Not Want To Stop Our Application Server After Running Our Tests.? |
|
Answer» It is possible to instruct COBERTURA to write the data FILE. One of your classes should call the static method net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData(). For example: you could add something like this to a “logout” method in your WEB application: It is possible to instruct Cobertura to write the data file. One of your classes should call the static method net.sourceforge.cobertura.coveragedata.ProjectData.saveGlobalProjectData(). For example: you could add something like this to a “logout” method in your web application: |
|
| 2. |
I’m Using Jboss. When I Stop The Server, The Coverage Data File Is Not Written. Or The Coverage Data File Is 0 Bytes. Or Cobertura-report And Cobertura-merge Complain That The Coverage Data File Is Invalid (possibly Throwing An Eofexception).? |
|
Answer» Cobertura only writes the COVERAGE data FILE at SHUTDOWN. It does this by adding a shutdown hook with Runtime.getRuntime().addShutdownHook(). JBoss has its own shutdown hook that calls System.halt() when its FINISHED. If the JBoss shutdown hook finishes before the Cobertura shutdown hook, then the CALL to System.halt() causes the JVM to halt and the cobertura.ser file will be incomplete. Cobertura only writes the coverage data file at shutdown. It does this by adding a shutdown hook with Runtime.getRuntime().addShutdownHook(). JBoss has its own shutdown hook that calls System.halt() when its finished. If the JBoss shutdown hook finishes before the Cobertura shutdown hook, then the call to System.halt() causes the JVM to halt and the cobertura.ser file will be incomplete. |
|
| 3. |
I Have Automated Tests That Use Httpunit/htmlunit/empirix/rational Robot, Can I Use Cobertura? |
|
Answer» Yes! The process is a bit more involved, but the concept is the same. First instrument your compiled classes. Then create your war FILE. Then deploy the war file into your application SERVER (Tomcat, JBoss, WebLogic, WebSphere, etc). Now run your tests. Yes! The process is a bit more involved, but the concept is the same. First instrument your compiled classes. Then create your war file. Then deploy the war file into your application server (Tomcat, JBoss, WebLogic, WebSphere, etc). Now run your tests. |
|
| 4. |
Is It Possible To Graphically Show My Test Coverage Over Time? |
|
Answer» YES, using QALab. From their website, QALab “allows DEVELOPERS, architects and PROJECT managers alike to be presented with a trend of the QA statistics of their project.” Yes, using QALab. From their website, QALab “allows developers, architects and project managers alike to be presented with a trend of the QA statistics of their project.” |
|
| 5. |
Why Is Cobertura Causing Me To Have Classpath Conflicts With Asm? |
|
Answer» COBERTURA uses ASM to modify your bytecode. There are a few other popular programs that use ASM; Groovy and Hibernate, to name two. You COULD have problems if Cobertura uses a different version of asm and you add both versions to your classpath. Cobertura uses ASM to modify your bytecode. There are a few other popular programs that use ASM; Groovy and Hibernate, to name two. You could have problems if Cobertura uses a different version of asm and you add both versions to your classpath. |
|
| 6. |
When I Generate Coverage Reports, Why Do They Always Show 100% Coverage Everywhere? |
|
Answer» Cobertura is probably using the wrong .SER file when generating the reports. When you instrument your classes, Cobertura generates a .ser file containing basic information about each class. As your tests run, Cobertura ADDS additional information to this same data file. If the instrumented classes can not find the data file when running then they will create a new one. It is important that you USE the same cobertura.ser file when instrumenting, running, and generating reports. Cobertura is probably using the wrong .ser file when generating the reports. When you instrument your classes, Cobertura generates a .ser file containing basic information about each class. As your tests run, Cobertura adds additional information to this same data file. If the instrumented classes can not find the data file when running then they will create a new one. It is important that you use the same cobertura.ser file when instrumenting, running, and generating reports. |
|
| 7. |
What Is Code Complexity And Why Should I Care About It? |
|
Answer» McCabe’s cyclomatic code complexity algorithm is used to determine how “COMPLEX” a given PIECE of code is. As code becomes more complex, it becomes more error prone. If a class has a HIGH complexity number, then that class is a good target for additional test coverage. McCabe’s cyclomatic code complexity algorithm is used to determine how “complex” a given piece of code is. As code becomes more complex, it becomes more error prone. If a class has a high complexity number, then that class is a good target for additional test coverage. |
|
| 8. |
What Do I Need To Use Cobertura? |
|
Answer» A computer with JAVA 1.3 or newer. We have run COBERTURA on Windows XP and Linux (Fedora CORE 4) USING the 1.4.2 JDK. However, it should work on any platform and with any 1.3 or newer JDK. The Cobertura download packages include all the dependencies you’ll need (ASM, log4j, etc.) A computer with Java 1.3 or newer. We have run Cobertura on Windows XP and Linux (Fedora Core 4) using the 1.4.2 JDK. However, it should work on any platform and with any 1.3 or newer JDK. The Cobertura download packages include all the dependencies you’ll need (ASM, log4j, etc.) |
|
| 9. |
What About Emma? |
|
Answer» We haven’t USED it very much, but it LOOKS like it does a pretty good job. Judging from the sample on the Emma web page, we think the Cobertura HTML reports are a BIT easier to DIGEST. It looks like Emma has some nice usability features, such as the ABILITY to instrument all classes in a jar file with one command. A little friendly competition never hurt anyone. We haven’t used it very much, but it looks like it does a pretty good job. Judging from the sample on the Emma web page, we think the Cobertura HTML reports are a bit easier to digest. It looks like Emma has some nice usability features, such as the ability to instrument all classes in a jar file with one command. A little friendly competition never hurt anyone. |
|
| 10. |
What Is Cobertura? |
|
Answer» Cobertura is an OPEN source tool that measures test coverage by instrumenting a code BASE and tracking the percentage of code that are executed as the test suite runs. It is based on jcoverage. In addition to identifying UNTESTED code and locating bugs, Cobertura can optimize code by flagging dead and unreachable code. Cobertura monitors tests by instrumenting the bytecode with extra statements to log which lines are and are not being reached as the test suite executes. It then produces a report in HTML or XML that shows exactly which packages, CLASSES, methods, and individual lines of code are not being tested. Cobertura is an open source tool that measures test coverage by instrumenting a code base and tracking the percentage of code that are executed as the test suite runs. It is based on jcoverage. In addition to identifying untested code and locating bugs, Cobertura can optimize code by flagging dead and unreachable code. Cobertura monitors tests by instrumenting the bytecode with extra statements to log which lines are and are not being reached as the test suite executes. It then produces a report in HTML or XML that shows exactly which packages, classes, methods, and individual lines of code are not being tested. |
|
| 11. |
Where Does The Name “cobertura” Come From? |
|
Answer» “Cobertura” is the Spanish and Portuguese WORD for “COVERAGE.” We were trying to avoid acronyms and coffee references. It’s not too hard to associate the word “cobertura” with the word “coverage,” and it even has a BIT of a zesty KICK to it! “Cobertura” is the Spanish and Portuguese word for “coverage.” We were trying to avoid acronyms and coffee references. It’s not too hard to associate the word “cobertura” with the word “coverage,” and it even has a bit of a zesty kick to it! |
|