To use Qlty’s code coverage features, you first need to generate coverage reports from your test suite. This page provides instructions for common languages and frameworks.Documentation Index
Fetch the complete documentation index at: https://docs.qlty.sh/llms.txt
Use this file to discover all available pages before exploring further.
Supported Languages and Formats
| Language | Format / Coverage Tool | File Extension |
|---|---|---|
| Ruby | Simplecov | .json |
| JavaScript | Lcov (generated by Istanbul) | .lcov, .info |
| Python | Cobertura (generated by pytest or coverage.py) | .xml |
| PHP | Clover | *.xml |
| Go | Clover | *.xml |
| Java | Cobertura and Jacoco | *.xml |
| Swift | Cobertura (using native Xcode coverage and slather) | *.xml |
| Kotlin | Cobertura and Jacoco | *.xml |
| C | Lcov (generated by gcov / lcov) | *.info |
| C++ | Lcov (generated by gcov / lcov) | *.info |
| .NET | dotCover | *.xml |
| Elixir | Lcov (Generated by lcov_ex) | *.info |
| Qlty | This is Qlty’s generic coverage format | *.jsonl |
Language-specific Instructions
JavaScript / TypeScript
JavaScript / TypeScript
JavaScript / TypeScript with Jest
Jest has built-in coverage reporting capabilities using Istanbul under the hood.coverage directory, including an LCOV report at coverage/lcov.info.React
If you’re using Create React App, Jest is already configured. Simply run:Node.js with NYC (Istanbul)
coverage/lcov.info.Python
Python
Ruby
Ruby
Ruby with SimpleCov
Add SimpleCov to your Gemfile:test/test_helper.rb or spec/spec_helper.rb):coverage/.resultset.json.Go
Go
Go
Go has built-in coverage capabilities:Java / Kotlin
Java / Kotlin
Java / Kotlin with Gradle and JaCoCo
Add JaCoCo to your Gradle build:build/reports/jacoco/test/jacocoTestReport.xml.Java / Kotlin with Maven and JaCoCo
Add JaCoCo to your Mavenpom.xml:target/site/jacoco/jacoco.xml.PHP
PHP
PHP with PHPUnit
Configure PHPUnit in yourphpunit.xml:coverage.xml.Swift
Swift
Swift Options
While there are multiple extraction options for Swift coverage data, each involves the same initial setup step: enable code coverage generation on your Xcode project or build. This can be done in your Xcode scheme, or via thexcodebuild command line option enableCodeCoverage YES.By providing these settings, Xcode will generate coverage data into a binary format. Coverage data next needs to be exported into a format recognized by Qlty.If you’re using Xcode 9.3 or later (recommended for most modern projects), we recommend using xccov to export coverage data, but you can also use Slather.If using an older version of Xcode, Slather is likely your best option.Using xccov (Xcode >= 9.3)
xccov was introduced in Xcode 9.3 as a simplified way to extract coverage data. xccov enables extracting coverage data from a single consolidated .xcresult bundle, greatly simplifying coverage setup. To use xccov:-
Find / specify the location of the
*.xcresultbundle If you are writing an Xcode build command yourself, you can supply it with the location where you’d like it to write the *.xcresult:If instead you are utilizing a CI provider’s Xcode test step which then executes Xcode on your behalf, examine the underlying xcodebuild command it uses. It may provide a standardized location for the.xcresultbundle. If not, the step may export an environment variable containing the path to the .xcresult bundle. -
Export coverage data using
xccov
--archive and --json are passed as arguments as follows:- When uploading this coverage data to Qlty, specify the format of the file as “xccov-json”
Swift with Xcode and Slather (see Slather’s documentation for supported Xcode versions)
Slather is a Ruby gem that extracts coverage data from Xcode projects.On the pro side, Slather supports a wide range of Xcode versions, supports excluding files from coverage, and is fairly easy to use.On the con side, Slather relies on lower level Apple tools likellvm-cov which is more complex and relies on being able to locate coverage-related files. On simple projects this may be fine. More complex multi-module projects need extra setup to ensure all coverage data is extracted. See Slather’s documentation for more information. In general the setup process is as follows:-
Install Slather
-
Create a
.slather.ymlfile: -
Run your tests and then generate a coverage report:
This will generate a Cobertura XML report in the
coveragedirectory. - When uploading coverage, specify the Cobertura format and provide the file generated by slather
Elixir
Elixir
Elixir with lcov_ex
Add lcov_ex to your dependencies inmix.exs:Option 1: Using the mix lcov task
Run the lcov task to run tests and generate coverage:cover/lcov.info.To output to a different folder:coverage/lcov.info.Option 2: Using mix test —cover
Alternatively, configureLcovEx as your test coverage tool in mix.exs:coverage/lcov.info.Umbrella Projects
For umbrella projects, runningmix lcov at the umbrella level will generate coverage reports for all individual apps and compile them into a single file at cover/lcov.info.To keep the individual app coverage files as well:Path Fixing
For Qlty to accurately match a coverage report file to files in your Git repository, paths must align. The paths in your coverage report should be relative to your Git project’s root, but this isn’t always the case by default. To resolve path mismatches, theqlty coverage publish command supports these flags:
--add-prefix: Adds a prefix to file paths in coverage payloads--strip-prefix: Removes a prefix from absolute paths in coverage payloads
Custom Formats with the Qlty Format
In the unlikely event that your coverage tool does not export coverage data in a supported format, you can convert your coverage data to theqlty format.
Learn more about the Qlty format
Next Steps
Once you’ve generated a coverage report, you can:- Upload it to Qlty
- Set up CI integration to automate uploads
- Merge multiple reports if you have parallel tests