- Go
- Python
- Java & Kotlin
- JavaScript & TypeScript
- Swift
Steps to generate coverage for each supported language.
Install gocover-cobertura
$ go get golang.org/x/tools/cmd/cover
$ go get github.com/t-yuki/gocover-cobertura
cd example-go
go test -race -coverprofile=coverage.txt -covermode=atomic
gocover-cobertura < coverage.txt > coverage.xml
Go native coverage is coverage.txt and cobertura is coverage.xml
pip3 install coverage
coverage run tests.py
coverage xml
.coverage from coverage run is the native coverage format.
coverage.xml from coverage xml is cobertura.
cd example-gradle
./gradlew check
./gradlew jacocoTestReport
Coverage file is in ./build/reports/jacoco/test/jacocoTestReport.xml
cd example-node
cd istanbul-mocha
npm install .
Create .istanbul.yml with:
reporting:
print: summary
reports:
- cobertura
Run npm run test
./coverage/coverage.json is the native format
./coverage/cobertura-coverage.xml is the cobertura format.
Install and configure Ruby.
brew install ruby
# ruby
export PATH="/usr/local/opt/ruby/bin:$PATH"
# Based on `gem environment gemdir`
export PATH="/usr/local/lib/ruby/gems/3.0.0/bin:$PATH"
Run tests and generate coverage.
cd example-swift
gem install slather
open SwiftExample.xcodeproj/
Product->Scheme->Edit Scheme.- Click on the
Testtarget and selectOptions... - Verify the
Code Coveragebox is checked and it saysGather coverage for all targets - Add new Scheme
SwiftExampleTestsand ensure theSharedbox is checked - Enable coverage for the newly added scheme
Run the tests:
xcodebuild test -scheme SwiftExampleTests -destination 'platform=iOS Simulator,name=iPhone 12,OS=latest' -derivedDataPath output
Process coverage
slather coverage -x --build-directory output --scheme SwiftExampleTests --binary-basename SwiftExample SwiftExample.xcodeproj
The coverage will be in cobertura.xml