Why This Line Is Not Covered? Xcode Code Coverage

Why isn't Xcode showing test coverage?

Works fine on my machine:

Sample Image

Sample Image

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:

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.

Sample Image

But if I change the syntax to an equivalent one-liner, the coverage goes to 100%.

Sample Image

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:

Partial code coverage

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



Leave a reply



Submit