Description
Xcode previews are currently reported as uncovered code in the code coverage report.
Reproduction
Adding a SwiftUI preview (even with the DEBUG
#if
statement) is still reported in the code coverage, e.g.:
#if DEBUG
struct Example_Previews: PreviewProvider {
static var previews: some View {
Example()
}
}
#endif
The behaviour can also be reproduced in different Spezi Swift Packages, including the diff code coverage in StanfordSpezi/SpeziAccount#6.
Expected behavior
The preview provides (or even the new #Preview
macro) should be excluded from the code coverage report based on the TEST
active compilation condition. The TEST
active compilation condition should be propagated in the compilation for tests, and the DEBUG
flag should ensure that the preview provider is built when showing a view in the Xcode preview.
Code of Conduct