coverage

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileCoverage

type FileCoverage struct {
	Path         string          `json:"path"`
	TotalLines   int             `json:"total_lines"`
	CoveredLines int             `json:"covered_lines"`
	CoverageRate float64         `json:"coverage_rate"`
	Lines        map[int]int     `json:"-"`
	Ranges       []RangeCoverage `json:"ranges,omitempty"`
}

FileCoverage represents coverage data for a single file.

type RangeCoverage

type RangeCoverage struct {
	StartLine int `json:"start_line"`
	EndLine   int `json:"end_line"`
	Count     int `json:"count"`
}

RangeCoverage records a covered line range.

type Report

type Report struct {
	Format       string                   `json:"format"`
	Files        map[string]*FileCoverage `json:"files"`
	TotalLines   int                      `json:"total_lines"`
	CoveredLines int                      `json:"covered_lines"`
	CoverageRate float64                  `json:"coverage_rate"`
}

Report holds the parsed test coverage report across all files.

func ParseCobertura

func ParseCobertura(r io.Reader) (*Report, error)

ParseCobertura parses Cobertura XML format.

func ParseCoverageFile

func ParseCoverageFile(filePath string) (*Report, error)

ParseCoverageFile reads and parses a coverage file, auto-detecting the format.

func ParseGoCover

func ParseGoCover(r io.Reader) (*Report, error)

ParseGoCover parses Go's standard coverprofile format.

func ParseJaCoCo

func ParseJaCoCo(r io.Reader) (*Report, error)

ParseJaCoCo parses the jacoco.xml written by the Maven and Gradle JaCoCo plugins. A file is keyed as "<package>/<sourcefile>", for example "com/acme/x/Foo.java": JaCoCo records no source root, so the key is relative to it. IsSymbolCovered already suffix-matches report paths against indexed paths, which resolves it to src/main/java/com/acme/x/Foo.java (or a Gradle module's src/main/kotlin) without a separate mapping.

A line counts as covered when any of its instructions ran (ci > 0), and as uncovered when none did but some exist (mi > 0). Lines with neither carry no executable code and are skipped, so they cannot dilute the rate. A partially covered line (mi > 0 and ci > 0) is covered: the line ran, which is the signal a line-level test-coverage map needs.

func ParseLCOV

func ParseLCOV(r io.Reader) (*Report, error)

ParseLCOV parses LCOV format (.info / .lcov).

func (*Report) IsSymbolCovered

func (r *Report) IsSymbolCovered(filePath string, startLine, endLine int) (covered bool, coveredCount, totalCount int)

IsSymbolCovered checks if a symbol range has test coverage.

func (*Report) Summary

func (r *Report) Summary() string

Summary returns a human-readable summary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL