Potential regression in test code coverage 1.23.8 1.24.10

97 views
Skip to first unread message

Laurent Caumont

unread,
Nov 26, 2025, 9:20:19 PM (9 days ago) Nov 26
to golang-nuts
I have some differences between these 2 versions on test coverage across packages.
I don't know if it's a bug or a new behavior.
In 1.23.8, a test run in one package also report coverage of functions used in other package. It's not the case with 1.24.10.
Example:
version 1.23.8
E:\\coverTest>go1.23.8.exe test -v test/test/pkg2 test/test/pkg1 -coverprofile=coverage.out
        test/test/pkg1          coverage: 0.0% of statements
=== RUN   TestFunc2
--- PASS: TestFunc2 (0.00s)
=== RUN   TestFunc2_ReturnsNonEmptyString
--- PASS: TestFunc2_ReturnsNonEmptyString (0.00s)
=== RUN   TestFunc2_ContainsExpectedPrefix
--- PASS: TestFunc2_ContainsExpectedPrefix (0.00s)
PASS
coverage: 100.0% of statements
ok      test/test/pkg2  1.025s  coverage: 100.0% of statements

E:\coverTest>go1.23.8.exe tool cover -func coverage.out
test/test/pkg1/file1.go:3:      Func1           100.0%
test/test/pkg2/file1.go:5:      Func2           100.0%
total:                          (statements)    100.0%

version 1.24.10
E:\coverTest>go1.24.10.exe test -v test/test/pkg2 test/test/pkg1 -coverprofile=coverage.out
=== RUN   TestFunc2
--- PASS: TestFunc2 (0.00s)
=== RUN   TestFunc2_ReturnsNonEmptyString
--- PASS: TestFunc2_ReturnsNonEmptyString (0.00s)
=== RUN   TestFunc2_ContainsExpectedPrefix
--- PASS: TestFunc2_ContainsExpectedPrefix (0.00s)
PASS
coverage: 100.0% of statements
ok      test/test/pkg2  0.110s  coverage: 100.0% of statements
        test/test/pkg1          coverage: 0.0% of statements

E:\coverTest>go1.24.10.exe tool cover -func coverage.out
test/test/pkg1/file1.go:3:      Func1           0.0%
test/test/pkg2/file1.go:5:      Func2           100.0%
total:                          (statements)    50.0%


Laurent Caumont

unread,
Nov 28, 2025, 6:07:12 AM (7 days ago) Nov 28
to golang-nuts
Reply all
Reply to author
Forward
0 new messages