Code coverage doesn't show up for files not called by the tests

Originator:keithbsmiley
Number:rdar://42562307 Date Originated:24-Jul-2018 04:51 PM
Status:Duplicate of 22578123 (open) Resolved:
Product:Developer Tools Product Version:Xcode 10.0 beta 4 (10L213o)
Classification:Other Bug Reproducible:Always
 
Summary:
In Swift projects using static libraries, if you don't call a function from one of your source files, the file doesn't show up as 0% covered in the coverage report.

Steps to Reproduce:
1. Create a new Swift static library project
2. Create a test target
3. Create 2 source files, Foo and Bar, add a top level function to both
4. Create 2 test files, FooTests and BarTests, add a test to both, from BarTests call the function you defined in Bar, in FooTests do not call any function from Foo
5. Setup your scheme to run the tests and capture coverage
6. Run the tests
7. View the code coverage report

Expected Results:
The coverage includes Foo.swift with 0% coverage

Actual Results:
Foo.swift doesn't appear in the coverage report, making it seem like you have higher code coverage than you really do.

Version:
Xcode 10.0 beta 4 (10L213o)

Notes:
- If you then call your function in Foo from FooTests, you'll see Foo appear in the coverage report
- Use the attached project for a repro example
- See screenshot.png for the view from Xcode, output.txt produced with `xccov view` and the `xccovreport` from my test of this

Comments

Missing attachments on Open Radar bug.

Could you please provide links for attachments (project, screenshot.png and output.txt) which were present in the original Apple Bug report but not present on Open Radar bug?

By cihan.cimen83 at Sept. 10, 2018, 5:47 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!