Why isn't Xcode showing test coverage?
Works fine on my machine:
Don't forget to choose Editor > Show Code Coverage (you didn't mention that in your little checklist).
XCode test coverage reports uncovered line with only braces
Here are possible variants:
a) preferred one (IMO)
var property: Type {
condition ? value1 : value2
}
b) and if you like explicit branches (or last your snapshot)
var property: Type {
var result = value2
if condition {
result = value1
}
return result
}
How to display Xcode code coverage when it's not displaying?
Issue Resolve in Version 9.3, to get the code coverage Target -> Test -> Options -> CodeCoverage See image:
Xcode - Strange Code Coverage of Swift Computed Property
I'd say it's a bug.
I reproduced your code in Xcode 10.2, and I'm getting the same behaviour.
But if I change the syntax to an equivalent one-liner, the coverage goes to 100%.
I suggest you open a radar. I'll be doing the same.
What is the meaning of rectangle areas with stripes, while having test coverage enabled in Xcode?
The striped rectangles indicate partial code coverage. Somebody just asked this question elsewhere and in looking at some test cases, I realized that if you hover your mouse over a line with the stripes, you get something like this:
As you'll notice, part of the line is green and part of it is red. The green part is for the condition which comes under code coverage since that part was executed. The red part is for the error message which was not executed since the test passed. Hope that makes sense?
Xcode test cases shows no test coverage
I tried many many things to get this fixed. Finally I ended up deleting all Xcode I had in the Mac, and cleared all the meta-data from /Users/bbirani/Library/Developer/
. After all this clean-up, I re-installed Xcode and VOILAA!! it started working.
Related Topics
Rxswift: Ondisposed Activated Before Alamofire Return Data
Swift & Firebase: Detect Revoked Token
Get The Start Point and End Point of The UIpangesturerecognizer in Swift
How to Split a String at The Last Occurence of a Sequence
Swift 4 Date Picker Wrong Value Using Minuteinterval
Can You Strict Generic Types or Give One Parameter More Than One Type
Swift Can Change Struct Declared with Let If Using an Index But Not If Using a Loop
Swift Combine How Set<Anycancellable> Works
What Is Swift Enum Byte Representation
Swift Unable to Locate and Read Property List (.Plist) File
How to a Convert a Dictionary Slice to a Dictionary in Swift
Key Data Not Storing to Icloud with Nsubiquitouskeyvaluestore.Defaultstore
How to Get Textfields from Static Cells in UItableviewcontroller? Swift