We are experiencing missing coverage for private variables in SwiftUI views after update from Xcode 14.3 to Xcode 14.2.
Steps to reproduce:
- Create new SwiftUI project in Xcode
- Enable code coverage
- Modify ContentView to
struct ContentView: View {
private let title = "Hello, world!"
let text: String
var body: some View {
VStack {
Text(title)
Text(text)
}
.padding()
}
}
- Run UITest - CoverageTestTests::testExample
- Check coverage in Xcode for
ContentView
Actual result: Line private let title = "Hello, world!"
is not covered.
Expected result: Line should be covered
Workaround: Generate initialiser for ContentView
init(text: String) {
self.text = text
}
Coverage is correct when initialiser is added explicitly
Test project: https://github.com/yuri-qualtie/CoverageTest