Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwiftUI Previews Are Not Excluded From the Test Coverage Results #11

Open
1 task done
PSchmiedmayer opened this issue Jun 14, 2023 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@PSchmiedmayer
Copy link
Member

PSchmiedmayer commented Jun 14, 2023

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

  • I agree to follow this project's Code of Conduct and Contributing Guidelines
@PSchmiedmayer PSchmiedmayer added the bug Something isn't working label Jun 14, 2023
@PSchmiedmayer PSchmiedmayer moved this to Backlog in Project Planning Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant