कवरेज रेसिपी

कवरेज रेसिपी

Fucini Coverage Studio जिसे पढ़ सके ऐसी कवरेज ट्रेसफ़ाइल बनाने के लिए कॉपी-पेस्ट कमांड — हर समर्थित कंपाइलर और टूलचेन के लिए।

VSIX डाउनलोड करें

Fucini Coverage Studio फ़ॉर्मेट-आधारित है, भाषा-आधारित नहीं: कोई भी भाषा जिसकी टूलचेन पच्चीस समर्थित फ़ॉर्मेट में से कोई एक बना सके, काम करती है। नीचे हर कंपाइलर के लिए ठोस रेसिपी है। कमांड <pre> ब्लॉक में हैं — उन्हें ज्यों का त्यों कॉपी करें और अपनी परियोजना के अनुसार नाम/पथ समायोजित करें।

फ़ॉर्मेटसामान्य फ़ाइलभाषाएँ
LCOVlcov.infoC, C++, Rust, Go
llvm-cov JSONcoverage.jsonC, C++, Obj-C, Rust, Swift
Cobertura XMLcoverage.xmlPython, .NET/C#, JS, PHP
JaCoCo XMLjacoco.xmlJava, Kotlin, Scala, Groovy
Istanbul / nyccoverage-final.jsonJavaScript, TypeScript
SimpleCov.resultset.jsonRuby
Clover XMLclover.xmlPHP, JavaScript
OpenCover XMLcoverage.opencover.xml.NET/C#, VB.NET
coverage.py JSONcoverage.jsonPython
gcov / gcovr JSONgcov --json-format, gcovr --jsonC, C++
Go coverage profilecoverage.outGo
gcov plain text*.gcovC, C++ (pre-GCC 9 toolchains)
VectorCASTcoverage.xmlC, C++, Ada
Testwell CTC++*.txt (ctcpost)C, C++
Lauterbach TRACE32*.xmlAny target the debugger traces
EMMA XMLcoverage.xmlJava, Delphi / Object Pascal
UCIS / Aldec UCDB*.xmlVHDL, Verilog, SystemVerilog
NCover XMLCoverage.xml.NET / C#
dotCover DetailedXMLdotCover.xml.NET / C#
PIT / Stryker (mutation)mutations.xml, mutation-report.jsonJava, Kotlin, Scala, JS, TS, C#

Swift llvm-cov JSON

Swift अंदरूनी तौर पर LLVM का उपयोग करता है, इसलिए टेस्ट बाइनरी और उसके मर्ज किए गए प्रोफ़ाइल से llvm-cov export --format=json द्वारा JSON निर्यात करें।

# 1. Run tests with coverage (Swift Package Manager)
swift test --enable-code-coverage

# 2. Resolve the profdata and test-binary paths
PROF=$(swift build --show-bin-path)/codecov/default.profdata
BIN=$(swift build --show-bin-path)/<PackageName>PackageTests.xctest/Contents/MacOS/<PackageName>PackageTests
# Linux: BIN=$(swift build --show-bin-path)/<PackageName>PackageTests.xctest

# 3. Export JSON
xcrun llvm-cov export "$BIN" -instr-profile "$PROF" -format=json > coverage.json
# Linux (no xcrun): llvm-cov export "$BIN" -instr-profile "$PROF" -format=json > coverage.json

Xcode परियोजनाएँ: xcodebuild test -enableCodeCoverage YES -derivedDataPath ./DerivedData से बिल्ड करें, फिर DerivedData के अंदर .profdata और ऐप बाइनरी खोजें और वही llvm-cov export चलाएँ।

Swift / Objective-C — Xcode report xccov JSON

The shortest path from an .xcresult: no profdata hunting, no binary paths, one command. Use it when you want percentages and per-function coverage quickly.

# 1. Run the tests
xcodebuild test -scheme MyApp -enableCodeCoverage YES -derivedDataPath ./DerivedData

# 2. Export the coverage report from the .xcresult
xcrun xccov view --report --json \
  ./DerivedData/Logs/Test/*.xcresult > coverage.json

Gutters stay empty for this format, by design. xccov reports how many of a file's lines are executable and how many were covered, but not which — that answer needs one xccov view --file run per file. Studio will not invent the missing line numbers, because an invented gutter is indistinguishable from a measured one. You get file percentages, per-function execution counts, CodeLens and the worst-covered rankings. For line-by-line highlighting, use the llvm-cov route above against the same build, or slather for Cobertura.

C / C++ — Clang / LLVM llvm-cov JSON

सबसे समृद्ध इनपुट: स्टेटमेंट, ब्रांच, फ़ंक्शन, रीजन, MC/DC और C++ टेम्पलेट इंस्टैंशिएशन कवरेज। C/C++ के लिए अनुशंसित।

# 1. Compile with instrumentation (add -fcoverage-mcdc on Clang 18+ for MC/DC)
clang++ -fprofile-instr-generate -fcoverage-mapping -o app main.cpp

# 2. Run the instrumented binary
LLVM_PROFILE_FILE="app.profraw" ./app

# 3. Merge raw profiles
llvm-profdata merge -sparse app.profraw -o app.profdata

# 4. Export JSON
llvm-cov export ./app -instr-profile=app.profdata -format=json > coverage.json

C / C++ — GCC LCOV / gcov JSON

GCC .gcda/.gcno डेटा देता है जिसे lcov (या gcovr) lcov.info में बदल देता है। gcov और gcovr स्वयं जो JSON लिखते हैं वह भी पढ़ा जाता है, जिससे रूपांतरण चरण पूरी तरह हट जाता है — ध्यान दें कि gcov --json-format अपना आउटपुट gzip करता है, जब तक आप --stdout न दें।

# 1. Compile with coverage flags (--coverage == -fprofile-arcs -ftest-coverage)
gcc --coverage -O0 -o app main.c

# 2. Run the binary (writes .gcda next to .gcno)
./app

# 3. Capture lcov.info and drop system/test files
lcov --capture --directory . --output-file lcov.info
lcov --remove lcov.info '/usr/*' '*/test/*' --output-file lcov.info

# Alternative: no conversion at all — native JSON
# gcovr --json coverage.json
# gcov --json-format --stdout app.gcda > coverage.json

# Alternative: gcovr straight to Cobertura or lcov
# gcovr --lcov lcov.info
# gcovr --cobertura coverage.xml

अपने GCC संस्करण से मेल खाता gcov उपयोग करें (जैसे gcc-13 के साथ gcov-13), अन्यथा .gcda में संस्करण-असंगति होगी।

Rust LCOV / llvm-cov JSON

सबसे आसान cargo-llvm-cov (cargo install cargo-llvm-cov) के साथ, जो आपके लिए Rust का LLVM इंस्ट्रुमेंटेशन संभालता है।

# LCOV
cargo llvm-cov --lcov --output-path lcov.info

# llvm-cov JSON (richer metrics)
cargo llvm-cov --json --output-path coverage.json

# Manual, without cargo-llvm-cov:
# RUSTFLAGS="-C instrument-coverage" cargo test
# llvm-profdata merge -sparse default_*.profraw -o cov.profdata
# llvm-cov export target/debug/<testbin> -instr-profile=cov.profdata -format=json > coverage.json

Go Go coverage profile

Go की मूल प्रोफ़ाइल सीधे पढ़ी जाती है — कोई रूपांतरण चरण नहीं। coverage.out उन फ़ाइल नामों में भी है जिन्हें खोज ढूँढ़ती है, इसलिए Go परियोजना को कोई कॉन्फ़िगरेशन नहीं चाहिए।

# Run tests with a coverage profile — that is the whole recipe
go test ./... -coverprofile=coverage.out

# Converting still works if your pipeline already does it:
# go install github.com/jandelgado/gcov2lcov@latest
# gcov2lcov -infile=coverage.out -outfile=lcov.info

Python coverage.py JSON

coverage.py (या pytest-cov) का उपयोग करें और उसका मूल JSON बनाएँ। Cobertura निर्यात के बजाय इसे चुनें: केवल JSON यह दर्ज करता है कि # pragma: no cover ने कौन-सी पंक्तियाँ बाहर रखीं, और Studio उस भेद को बनाए रखता है, उन्हें कवर हुआ या छूटा हुआ नहीं गिनता।

# coverage.py — native JSON (recommended)
coverage run --branch -m pytest
coverage json           # -> coverage.json

# The Cobertura export still works
coverage xml            # -> coverage.xml (Cobertura)

# or pytest-cov in one step
pytest --cov=my_package --cov-report=xml

Java / Kotlin JaCoCo XML

JaCoCo वह XML रिपोर्ट बनाता है जिसे Studio पढ़ता है — सुनिश्चित करें कि XML फ़ॉर्मेट सक्षम है (HTML रिपोर्ट नहीं पढ़ी जाती)।

# Maven (jacoco-maven-plugin configured, XML format on)
mvn test
# -> target/site/jacoco/jacoco.xml

# Gradle
# build.gradle: jacocoTestReport { reports { xml.required = true } }
./gradlew test jacocoTestReport
# -> build/reports/jacoco/test/jacocoTestReport.xml

JavaScript / TypeScript Istanbul / nyc

Istanbul (nyc, Jest या Vitest के ज़रिए) coverage-final.json बनाता है। इसके Clover और Cobertura रिपोर्टर भी पढ़े जाते हैं — Vitest डिफ़ॉल्ट रूप से Clover लिखता है, इसलिए Vitest परियोजना में अक्सर पहले से ही ऐसी फ़ाइल होती है जिसे Studio खोल सकता है।

# nyc
npx nyc --reporter=json mocha           # -> coverage/coverage-final.json

# Jest (Istanbul built in)
jest --coverage --coverageReporters=json

# Vitest
vitest run --coverage --coverage.reporter=json

# Clover      --coverageReporters=clover     (-> coverage/clover.xml)
# Cobertura   --coverageReporters=cobertura  (-> cobertura-coverage.xml)

.NET / C# OpenCover / Cobertura XML

dotnet test के दौरान coverlet से कवरेज एकत्र करें। इसके दोनों XML प्रारूप पढ़े जाते हैं; OpenCover को प्राथमिकता दें, जो शाखा की हर भुजा के लिए विज़िट गिनती दर्ज करता है, जबकि Cobertura केवल यह बताता है कि उनमें से कितनी भुजाएँ कवर हुईं।

# OpenCover — keeps per-arm branch counts (recommended)
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
# -> coverage.opencover.xml

# Cobertura, via Coverlet's data collector
dotnet test --collect:"XPlat Code Coverage"
# -> TestResults/<guid>/coverage.cobertura.xml

PHP Clover XML

कवरेज ड्राइवर के रूप में Xdebug या PCOV के साथ PHPUnit चलाएँ और Clover लिखें — वह प्रारूप जो php-code-coverage डिफ़ॉल्ट रूप से बनाता है और जो अधिकांश परियोजनाओं में पहले से कॉन्फ़िगर है। यदि आपकी पाइपलाइन इसके बजाय Cobertura देती है, तो वह भी पढ़ी जाती है।

XDEBUG_MODE=coverage phpunit --coverage-clover clover.xml

# phpunit.xml alternative:
# <coverage><report><clover outputFile="clover.xml"/></report></coverage>

# Cobertura also works:
# XDEBUG_MODE=coverage phpunit --coverage-cobertura coverage.xml

Ruby SimpleCov

SimpleCov का JSON फ़ॉर्मैटर (gem 'simplecov-json') सेट करें ताकि मशीन-पठनीय coverage.json लिखा जाए।

# test_helper.rb / spec_helper.rb (before loading your code)
require 'simplecov'
require 'simplecov-json'
SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
SimpleCov.start

# then run your tests normally
rake test        # or: rspec
# -> coverage/coverage.json  (or .resultset.json)

Ada — GNATcoverage GNATcov XML

The format DO-178C and EN 50128 teams actually produce. --annotate=xml writes a directory, not a file: load the per-source *.xml files, several at once if you like.

# 1. Instrument and build
gnatcov instrument --level=stmt+mcdc --projects my_project.gpr
gprbuild -P my_project.gpr --src-subdirs=gnatcov-instr --implicit-with=gnatcov_rts

# 2. Run, then produce XML
gnatcov coverage --level=stmt+mcdc --annotate=xml \
  --output-dir=coverage/ my_project.gpr obj/my_program.srctrace
# -> coverage/*.xml  (one per source; index.xml is just a directory listing)

A partially covered line (!) stays a covered line with an uncovered decision — the shortfall appears in branch and MC/DC coverage, where it belongs, rather than being written off as an uncovered line. pragma Annotate (Xcov, Exempt_On) regions become excluded lines. With --level=stmt+mcdc, MC/DC drives the compliance gate and the composite score.

C / C++ — BullseyeCoverage Bullseye XML

The commercial tool most embedded and safety-critical teams already own. Its headline metric is condition/decision coverage rather than line coverage, and Studio keeps the two separate rather than blending them.

# 1. Build with the Bullseye compiler wrappers on PATH, then run your tests
cov01 -1                 # enable instrumentation
make && ./run_tests

# 2. Export XML
covxml -f test.cov -o coverage.xml

A single-outcome probe is scored out of one rather than two, so a fully tested switch is not reported as half covered.

.NET — MSTest / vstest Visual Studio .coveragexml

For teams on vstest rather than Coverlet. The binary .coverage file has to be converted first.

dotnet test --collect:"Code Coverage"
dotnet-coverage convert -o coverage.coveragexml TestResults/**/*.coverage

Any language — Coveralls JSON Coveralls

If you already upload to Coveralls, the payload your reporter builds loads here directly — line-level, so gutters work. Reporters exist for most ecosystems: coveralls-lcov, excoveralls (Elixir), coveralls-python, simplecov-coveralls (Ruby), goveralls (Go), cargo-tarpaulin --out Coveralls (Rust) and node-coveralls.

# Example: Elixir, writing the payload instead of posting it
MIX_ENV=test mix coveralls.json
# -> cover/excoveralls.json

# Example: Rust
cargo tarpaulin --out Coveralls --output-dir .

A null in the coverage array means the line is not executable — a blank, a comment, a brace — and is excluded from the totals rather than counted as a miss.

Any language — SonarQube generic Generic coverage XML

SonarQube's own hand-written format, for a language with no native tool of its own. Useful mainly when something upstream already emits it.

<coverage version="1">
  <file path="src/a.c">
    <lineToCover lineNumber="5" covered="true"/>
    <lineToCover lineNumber="6" covered="false"/>
  </file>
</coverage>

C / C++ / Ada — VectorCAST VectorCAST XML

VectorCAST writes a Cobertura report with extra attributes attached — mcdcpair-coverage, function-coverage and functioncall-coverage — that plain Cobertura tooling ignores and this reader keeps. No conversion step: point Studio at the report VectorCAST already writes.

# From the VectorCAST GUI or vcast_gui.py, export the Cobertura-format report
# (Environment / Project → Reports → Cobertura), or via the API:
clicast -e <env> report custom Cobertura coverage.xml

The MC/DC pair counts drive the MC/DC gate and composite score exactly as GNATcoverage's do. Function-call coverage is read as its own metric, not folded into branches.

C / C++ — Testwell CTC++ CTC++ text listing

The tool that sits opposite Bullseye in European embedded and safety evaluations, and the one that measures multicondition coverage. Load the execution-profile listing as-is — no conversion, and no trip through Cobertura that would flatten it.

# 1. Instrument and build (per CTC++'s compiler wrapper for your toolchain)
ctc++ gcc -c file.c -o file.o
ctc++ gcc file.o -o app

# 2. Run the instrumented binary (writes MON.sym / MON.dat)
./app

# 3. Produce the text listing
ctcpost --projectfile ctc.proj -m src -t profile.txt

Newer CTC++ installs can skip the listing entirely. ctcpost's LCOV template (-m lcov, where the installed template set includes it) writes LCOV directly, which loads here with no format-specific parsing at all. Use the text listing when only multicondition coverage matters — LCOV has no place for it, and it is reported here as branch coverage rather than as MC/DC, since the two ask different questions.

Any target — Lauterbach TRACE32 TRACE32 XML

The on-chip-trace route: a debugger reports the instruction stream a real target actually executed, with no instrumentation and no probe effect on timing. An export carries exactly one metric — run it once per metric you need, and load all the exports together.

# From a TRACE32 PRACTICE script (.cmm), after a trace-based run:
COVerage.EXPORT.ListModule stmt.xml metric=stmt
COVerage.EXPORT.ListModule mcdc.xml metric=mcdc
COVerage.EXPORT.ListModule func.xml metric=func
COVerage.EXPORT.ListModule call.xml metric=call
COVerage.EXPORT.ListModule object.xml metric=object

stmt becomes line coverage; dec/cond become branch coverage; mcdc drives the MC/DC gate; func and call feed function and function-call coverage; object is the one export that produces object-code coverage. Loading several exports of the same run merges them by module name.

VHDL — GHDL LCOV / gcov JSON

Open-source VHDL simulation already has a way in through GHDL's GCC backend — no dedicated parser needed, because the result is ordinary gcov data.

# 1. Analyse and elaborate with coverage instrumentation
ghdl -a --coverage=stmt,cond your_design.vhd your_testbench.vhd
ghdl -e --coverage=stmt,cond your_testbench

# 2. Run the testbench (writes .gcda next to .gcno)
ghdl -r your_testbench

# 3. Capture as usual
lcov --capture --directory . --output-file lcov.info
# or: gcovr --json coverage.json

For commercial simulators (Riviera-PRO, Active-HDL, QuestaSim), see UCIS/UCDB below instead.

VHDL / Verilog / SystemVerilog — UCIS / Aldec UCDB UCIS / UCDB XML

Two documents answer to this name; load whichever your simulator writes. Statement and branch coverage come across — toggle, FSM, assertion and functional coverage are HDL-specific concepts with no equivalent metric here, and are not read.

# Accellera-standard UCIS interchange (Questa, VCS, Xcelium — consult your
# simulator's manual for the exact export command, typically via its GUI
# or a `ucis` command-line utility)

# Aldec Riviera-PRO / Active-HDL — native .ucdb converted to UCIS XML
acdb2xml -i coverage.ucdb -o coverage.xml

Beckhoff TwinCAT 3 Visual Studio .coveragexml

TwinCAT 3's C++ modules compile with MSVC inside Visual Studio, so ordinary .NET/C++ coverage tooling already applies — see MSTest/vstest above, or OpenCppCoverage for an instrumentation-free alternative. The Structured Text (ST) half has no coverage tool at all, from Beckhoff or any third party; if your project is ST-only, there is currently nothing to load here.

# OpenCppCoverage against a TwinCAT C++ module's unit tests
OpenCppCoverage.exe --sources=MyModule --export_type=cobertura:coverage.xml -- MyModuleTests.exe

Simulink Coverage's own report has no format this extension reads directly. A short MATLAB script walking the cvdata object produced by cvsim or cvload can write SonarQube's generic coverage XML, which is four attributes on two elements — well within reach of a project's own build script.

% Sketch: iterate cvdata's per-line decision/condition results and
% write <coverage version="1"><file path="..."><lineToCover .../>
% See the SonarQube example in the table above for the exact schema.
cv_data = cvload('model_cvdata.cvt');
% ... walk cv_data.get('metric_summary') per model block ...

CODESYS Not supported

CODESYS's own Profiler cannot say which statements ran — only how much time a POU spent — and its counters live in the runtime's RAM, clearing on a warm reset with no export this extension could read. If your PLC toolchain is Siemens instead, TIA Portal exports coverage data through its own test-management tooling that can be converted to SonarQube's generic format the same way as Simulink above.

.NET / C# — NCover NCover XML

NCover's Coverage.xml outlived the tool itself: a decade of build scripts and other coverage tools still write or consume this schema. Load it as-is, no conversion needed.

NCover.Console.exe //x Coverage.xml -- dotnet test

.NET / C# — JetBrains dotCover dotCover DetailedXML

The report type matters. dotCover's plain Xml report is a rollup with no line numbers at all; ask for DetailedXml specifically.

dotnet dotcover.dll cover --Output=dotCover.dcvr --TargetExecutable=dotnet --TargetArguments="test"
dotnet dotcover.dll report --Source=dotCover.dcvr --Output=dotCover.xml --ReportType=DetailedXML

JetBrains deprecated DetailedXml in dotCover 2025.2 — check your installed version's documentation for the current flag spelling if this one is rejected.

Delphi / Object Pascal & legacy Java — EMMA EMMA XML

Delphi has no lcov, no Cobertura, nothing else this extension reads — DelphiCodeCoverage is the way in. The same schema is also what a good deal of older Java tooling still emits.

# DelphiCodeCoverage, with per-line hit counts (needed for gutters)
DelphiCodeCoverage.exe -e MyApp.exe -m MyApp.map -xml -xmllines -o coverage.xml

Without -xmllines the report is a rollup percentage only — Studio shows a file summary and no gutters for it, the same treatment Xcode's xccov gets, rather than guessing which lines ran.

Any language — PIT / Stryker Mutation reports

Mutation testing answers a question coverage cannot: not whether a line ran, but whether anything failed when it was changed. Load the report beside a real coverage tracefile — the two merge by path, and the mutation score appears as its own metric, never averaged into the composite score.

# PIT — Java, Kotlin, Scala
mvn org.pitest:pitest-maven:mutationCoverage
# -> target/pit-reports/<timestamp>/mutations.xml

# Stryker — JavaScript, TypeScript, C#, Scala
npx stryker run
# -> reports/mutation/mutation.json (rename or point discovery at it)

Already covered, with no work at all

A few ecosystems reach Studio through a format it already reads, so there is nothing extra to install or configure:

  • Rust — cargo llvm-cov --lcov or grcov both emit LCOV; cargo llvm-cov --json emits llvm-cov JSON.
  • Kotlin — Kover writes JaCoCo XML.
  • Dart / Flutter — flutter test --coverage writes coverage/lcov.info.
  • PHP — PHPUnit's --coverage-clover is Clover XML.
  • Qt / Squish Coco — exports Cobertura or LCOV.
  • Erlang — rebar3 cover converts to Cobertura via covertool.
  • Elixir — excoveralls writes Coveralls JSON directly (mix coveralls.json).
  • Haskell — hpc coverage converts to Cobertura or LCOV via hpc-lcov.
  • Perl — Devel::Cover's -report clover writes Clover XML.
  • R — the covr package's to_cobertura() writes Cobertura XML.
  • Julia — Coverage.jl's LCOV.writefile writes LCOV directly.
  • Fortran — GCC-based (gfortran --coverage) goes through gcov/lcov like C.
  • PL/SQL — Oracle's DBMS_PLSQL_CODE_COVERAGE exports convert to Cobertura via community tooling (e.g. plsql-cover).

परिणाम को Studio में लोड करना

  1. ट्रेसफ़ाइल को अपने workspace में रखें (जैसे परियोजना रूट)।
  2. कमांड पैलेट → Fucini Coverage: Load Coverage — या watch.enabled चालू रहने दें (डिफ़ॉल्ट) और यह स्वतः लोड हो जाएगा।
  3. एक कवर की गई स्रोत फ़ाइल खोलें: कवर की गई पंक्तियाँ हिट-गणना के साथ हरा गटर पाती हैं, बिना कवर वाली लाल, और Covered Files व्यू भर जाता है।

सामान्य सुझाव (सभी भाषाएँ)

  • स्रोत-से-कवरेज 1:1 मैपिंग के लिए ऑप्टिमाइज़ेशन बंद (-O0) रखकर बिल्ड/टेस्ट करें; ऑप्टिमाइज़र पंक्तियाँ मर्ज या हटा सकते हैं।
  • संयुक्त स्कोर विकृत न हो, इसके लिए हमेशा थर्ड-पार्टी/टेस्ट कोड फ़िल्टर करें (ignore/remove फ़्लैग)।
  • कई ट्रेसफ़ाइलें? सभी लोड करें — Studio उन्हें दर्ज उद्गम के साथ नियतात्मक रूप से एक रन में मर्ज करता है।
  • यदि CI पथ आपके checkout से भिन्न हैं, तो fuciniCoverage पथ री-मैपिंग उपयोग करें (देखें उपयोगकर्ता गाइड §7)।