Code coverage do not include code covered with UITests - ios

In my simple app I have a few files that are tested by unit testing and uitesting.
I am pretty sure that in UITests I tested EVERY line in WLLoginViewController. The test passed, but it is not considered as 100% in code coverage for that file. Sometimes when I restart Xcode, run app again, clean app, hard clean app. Do some accidental things, it works. But run tests once again, and again it is not considered. Why? Any ideas how to fix it? Is it a bug?

As you already mentioned, sometimes Xcode says that you are testing 100% of your code and sometimes it doesn't. So it's really inconsistent. That is an indicator for a bug.
Since you are still using an Xcode-beta, it's most likely a bug in Xcode. I wouldn't worry to much since it's still a beta-version and would check later, when the final version is released.

Ok, I've found temporary workaround.
Remove derived data for your project (window->projects)
Quit Xcode and Simulator.
Launch Xcode with your project, and run tests.
Run tests again.
Remember to wait until indexing is finished:
Weird, but try and see:)

Related

Xcode test cases shows no test coverage

I'm having problem with getting code coverage in Xcode. It was working at some point of time, however after sometime it has just stopped showing coverage. I've checked both the schemes and test coverage plane for the appropriate settings.
This is how my scheme looks like:
This is what my test coverage plane shows after running test cases:
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.
It happens to me a lot. Try restarting your xcode as well as the simulator(if you are using one). It seems like an xcode issue.
You can try some of this
Enabling the "show code coverage" from Editor while running a test case. I had this same problem before worked for me. Just try and see if that is working.
You can try checking the targets for the modules but not sure thats the case.
Or you can use the #testable way.This is a workaround and the long way to solve this.
Also u can try cleaning the whole project and deleting any derived data.And then try running the test case.
Also you can try deleting the scheme and try making a new scheme and check "Gather coverage data" for the same. If this things work then thats a xcode bug.
I hope your problem gets solved, I got stuck to the same problem before and it was frustrating to solve that, and you never know which way might work.
Maybe try using Slather instead?
https://cocoacasts.com/how-to-generate-code-coverage-reports-in-xcode-with-slather

Cannot run program in Xcode

I've recently made an app and could successfully run and test it until this suddenly happened,
fail to run program
It doesn't looks like an issue, but the "run" button is unavailable. Usually it should look something like,
successfully run a program
As in the image, first there are two buttons, run and stop, after that there is the name of the program/app and its icon (fun facts) and then the iphone simulator it will run on (iphone 6). On the image on top, the failed to run program attempt, it is totally different, first the run button is disabled, second, the icon is a gear and not the app icon, and third, there is no simulator, it appears "my mac".
I don't know why this happened but this cannot let me run the app. I searched in the apple documentation and didn't found anything. If someone knows how to solve this please tell me.
The simplest solution is to rebuild your project from scratch. This is not difficult because you still have all your code. So, start with a new project from the iOS template. Copy your code from the old project into the new project.
And try to avoid renaming your project from now on, because there is a bug in some versions of Xcode where it crashes and destroys the project in just the way you describe in your question.
And update to the latest version of Xcode, because it is less likely to cause this problem (though in fact I have not found it reliable for renaming projects even now).

Cannot run XCTests

So, I was testing, then I probably did something to mess Xcode up because now no tests will appear:
I can, however, run the target and it will correctly run the tests (in this case testSignup).
Any idea how I can enable it again? I've tried clearing derived data, quitting Xcode, cleaning and restarting.
What I do when tests get messed up (which happens quite often, actually) is to delete the test target and make a new test target. If you have any tests you've already written, copy them first!

Xcode rebuilds project when nothing has changed

In the last few months we've noticed that Xcode seems to be rebuilding our project every time we 'Run', even if no files have changed. How do I determine what is causing this to happen so that I can prevent it?
We did start using Swift in the last few months as well...not sure if it's related.
Also, one reason that the problem is so noticeable is because of some extra build phases that we have which execute shell scripts that take time.
I am not sure if it's intention by Apple, or an Xcode bug. However, you can select ⌘⇧R (command+shift+R) to rerun without rebuilding.

Xcode 6 Code Sense stops working after build

So this same problem exists for a long time apparently. I checked all the xcode 4 code sense problems and used their solution and it works. Right up untill I build the file to run and then code sense stops working. I Really dont want to keep deleting the file in organizer and restarting xcode everytime. Is there a simpler method to fix this.
The first thing I always do when I lose Code Sense is to clean the project. If that doesn't work I use Watchdog to clean it. Watchdog deletes the derived data for the project like you can do in Organizer but it allows you to set up a handy keyboard shortcut which saves a ton of time now that Organizer doesn't have a keyboard shortcut.

Resources