Cobertura is an open-source code coverage tool for Java. It instruments compiled class files and records which lines and branches run during your tests in a cobertura.ser data file. It then turns that data into HTML and XML reports. Many CI tools still read its XML report format, even when a different tool produced the coverage data.

The posts here start with an overview of Cobertura's use cases, features and installation, plus a getting-started tutorial. Broader posts compare code coverage tools for Java, C, C++ and .NET. An Ant script example shows how to instrument class files. Short forum-style threads cover specific problems: checking whether a class is instrumented, confirming cobertura.jar is loaded in the JVM when tests write nothing to the .ser file, merging two data files, and fixing the "Could not find or load main class" error on Windows.

A list of 50 interview questions completes the set. The material is for Java developers and build engineers who maintain older Cobertura setups, and for anyone learning how coverage measurement works.

Start here

Latest Cobertura articles

What is Cobertura and use cases of Cobertura ?

What is Cobertura ? Cobertura is an open-source code coverage tool for Java projects. It helps developers measure the code coverage of their tests by analyzing which…

Read More

Code Coverage tools in 2024

In the ever-evolving realm of software development, code coverage tools remain crucial for measuring test effectiveness and ensuring code quality. As we enter 2024, here’s a glimpse…

Read More

Top 50 Cobertura interview questions and answers

1) Where Does The Name “cobertura” Come From? “Cobertura” is the Spanish and Portuguese word for “coverage.” We were trying to avoid acronyms and coffee references. It’s…

Read More

What Is Code Coverage? Top 5 Tools for C, C++, Java and .NET

What is Code Coverage?Code Coverage is a software which is used by the programmer.Code Coverage are mainly used for measuring the Lines, Blocks and Arc which they…

Read More

How to verify of cobertura.jar file is loaded into jvm

scmuser created the topic: How to verify of cobertura.jar file is loaded into jvm How to verify of cobertura.jar file is loaded into jvm? I have instrumented…

Read More

Cobertura – how to check if class file is instrumented or not?

scmuser created the topic: Cobertura – how to check if class file is instrumented or not? Hi, Could you please tell me how to check if class…

Read More

Cobertura merge two instrumented data file

scmuser created the topic: cobertura merge two instrumented data file Hi, Is it possible to merge two diff data file “cobertura.ser” file from two diff instrumentation? Rajesh…

Read More

Could not find or load main class net.sourceforge.cobertura.instrument

scmuser replied the topic: Could not find or load main class net.sourceforge.cobertura.instrument Still could not resolve the issues as below; [code language=”css”] C:\Users\rkumar11>cd C:\cobertura [/code] [code language=”css”]…

Read More

Instrumentating class file using Ant in Cobertura

rajeshkumar created the topic: Instrumentating class file using Ant in Cobertura Instrumentating class file using Ant in Cobertura Cobertura’s documentation gives the following example to show how…

Read More

Seeking in and out of Cobertura

mnanjala created the topic: Seeking in and out of Cobertura Hi All, I need all info about Cobertura How we can implement?How much time it would need…

Read More

Cobertura: frequently asked questions

What is Cobertura used for?

Cobertura measures how much of your Java code your tests exercise, reporting line and branch coverage. Teams use it to find untested code and to track coverage in builds.

Is Cobertura still maintained, and what is the alternative?

Cobertura's development has largely stalled, and it has trouble with newer Java bytecode. Many Java projects now use JaCoCo instead, although the Cobertura XML report format is still widely supported.

How do you merge two Cobertura .ser files?

Cobertura includes a merge utility, available as the cobertura-merge script and as an Ant task. It combines several data files into one so you can produce a single report.

Why do I get "Could not find or load main class net.sourceforge.cobertura"?

The error usually means the Cobertura jar or its dependencies, such as ASM, aren't on the classpath that the script or build uses. Check the paths the script sets and the directory you run it from.