Cobertura Interview Questions & Answers

Cobertura Interview Questions

Wisdom jobs Cobertura Interview Questions and answers have been framed specially to get you prepared for the most frequently asked questions in many job interviews. Here we have provided Tips and Tricks for cracking Cobertura interview Questions. These Cobertura Interview questions and answers are useful for Beginner, Advanced Experienced programmers and job seekers of different experience levels. It's a good idea to go through Cobertura Interview Questions. All the best in your job search.

Cobertura Interview Questions And Answers

    1. Question 1. 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!

    2. Question 2. 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.

    3. Question 3. 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.

    4. Question 4. 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.)

    5. Question 5. 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.

    6. Question 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.

      The best way to do this is to specify the location of the data file when running your tests. You should pass the -Dnet.sourceforge.cobertura.datafile=${basedir}/cobertura.ser sysproperty to the JUnit task.

      Another common problem is that the cobertura.ser file is deleted, but the previously instrumented classes are not also deleted. Any time you delete your coverage data file you should also deleted all instrumented classes.

    7. Question 7. 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 only uses ASM when instrumenting. Cobertura does not need ASM in your classpath when running tests. If you’re seeing classpath conflicts, just make sure the asm jar that comes with Cobertura is used only by Cobertura, and only when instrumenting.

    8. Question 8. 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.”

    9. Question 9. 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.

      As your classes are accessed, they will create a “cobertura.ser” file on the disk. You may need to dig around a bit to find it. Cobertura puts this file in what it considers to be the current working directory. Typically this is the directory that the application server was started from (for example, C:Tomcatbin) Note: This file is not written to the disk until the application server exits. See below for how to work around this.

      Now that you know where the cobertura.ser file is, you should modify your deploy step so that it moves the original cobertura.ser to the appropriate directory in your application server, and then moves it back when finished testing. Then run cobertura-report.

    10. Question 10. 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.

      To fix this, set -Djboss.shutdown.forceHalt=false when starting JBoss.

    11. Question 11. 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:

      try {
              String className = "net.sourceforge.cobertura.coveragedata.ProjectData";
              String methodName = "saveGlobalProjectData";
              Class saveClass = Class.forName(className);
              java.lang.reflect.Method saveMethod = saveClass.getDeclaredMethod(methodName, new Class[0]);
              saveMethod.invoke(null,new Object[0]);
          } catch (Throwable t) {

Popular Interview Questions

All Interview Questions

All Practice Tests

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status