Skip to content

testing: coverprofile can't profile coverage of test cases themselves #53508

@seebs

Description

@seebs

What version of Go are you using (go version)?

1.18

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

N/A, but Mac or Linux both.

What did you do?

Wrote test cases with non-trivial infrastructure and used -coverprofile.

What did you expect to see?

Coverage information for my test code and test infrastructure.

What did you see instead?

Coverage information only for the package being tested.

The issue here is that in some cases, tests may reasonably want some non-trivial infrastructure or setup code, which isn't logically relevant to the package outside of its unit tests, but which is complex enough that I want to be carefully verifying that code too, not just the overall results of unit tests using it. Being able to confirm/deny that the test code is running as expected, and not skipping things early or happening to hit only happy paths in the test logic, would be useful for diagnosing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions