lcov-cobertura is a Python library that converts code coverage reports from the LCOV format to the Cobertura XML format. This conversion is crucial for integration with Continuous Integration (CI) servers like Jenkins, which often use Cobertura XML to aggregate results and assess build stability. The library is actively maintained, with the current version 2.1.1 released in February 2025, and supports Python 3.8 and newer versions.
pip install lcov_coberturaVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use LcovCobertura as a Python module to convert LCOV data to Cobertura XML. The `base_dir` parameter is important for correctly resolving source file paths within the Cobertura report.
Upgrade your Python environment to 3.8 or newer, or use lcov-cobertura version 1.6 or older (not recommended due to lack of maintenance).
Ensure `c++filt` (part of GNU Binutils) is installed and accessible in the system's PATH if C++ demangling is required.
Always verify that `base_dir` points to the root directory where your source files are located relative to the paths in your LCOV report.
Upgrade your Python environment to version 3.8 or newer. If upgrading Python is not feasible, use an older version of lcov-cobertura (e.g., 1.6 or older), though this is not recommended due to lack of maintenance.
Ensure your Python environment is set up correctly, and if you are on a very recent Python version, consider if there's an update to lcov-cobertura that removes this dependency or if a compatibility layer is needed. For NixOS users, this might require adding `setuptools` as a dependency.
Ensure `lcov-cobertura` is installed via `pip install lcov_cobertura`. If already installed, verify that your system's PATH includes the directory where pip installs executables. For older versions, directly running the Python script might be necessary: `python -m lcov_cobertura lcov-file.dat`.
Install GNU Binutils (which includes `c++filt`) and ensure its location is accessible in your system's PATH environment variable.
Always verify that the `--base-dir` (or `base_dir`) parameter points to the root directory where your source files are located, relative to the paths reported in your LCOV file. The default is the current working directory.