I'm using Xcode 9 and I'm trying to write unit tests following the Apple iOS tutorial here.
Problem is that my unit tests aren't being discovered, only the stub in another test project in the same solution.
The test in the screenshot should fail, but it doesn't as it's not discovered.
The testExample method is shown below
As you can see it has the little diamond indicating it has a test, but not next to the one I've created. Is there anything I'm doing wrong?
The answer to this was to prefix the function name with test
So the function now looks like
And the test is now discovered in the test explorer
Related
I'm writing my own Pod and wanted to start unit Testing. But I can't figure out where in my Project to test.
I thought the Example Project was the right place to write my Tests, but from there I don't have internal Access to my DevelopmentPod.
I have to say it's the first XCode Project in which I want to unit test. So I'm not very familiar with it.
Any help on how unit Testing in Cocoapods should be set up is really appreciated.
I use XCode 7.2 and Swift 2.0, no extra pods for testing, just XCTestCase class. I don't have #testable import myApp and adding it doesn't fix my problem.
I have everything set up correctly to see code coverage for my Swift project (I have set it up following this post - How to use code coverage in Xcode 7? ).
And it works, when I run all tests (with Command-U). However, when I try to run a particular test class (e.g. CuriousUITests: XCTestCase) or a specific test (e.g. testMyFavouriteButton), the coverage shows as if none of the code is covered!
Why does that happen?
I want to be able to see code coverage when running just one test, so that after implementing a new test, I don't have to run all of my tests to see if it indeed does cover what I expected (It just takes too long to run them all).
Thanks for all your help!
da-na
When I try to test my iOS app the Xcode 7 test navigator shows (null) the second time I run my tests.
The first time it looks normal:
However, as I run the tests again the 12 tests turn into a single test named (null) and it feels like the test cases aren't really run anymore, they just succeed every time after 1 millisecond.
I'm using Kiwi for the tests, but it feels more like something going wrong in Xcode7. I don't remember having this problem in Xcode6. The only thing that consistently solves the problem seems to be an Xcode reboot.
Has anyone had this issue as well?
I have just experienced the same issue. Commenting out the test class name so the test would not build and then putting the test class name back fixed it for me.
I've got a large iOS project set up with OCUnit tests, some of which are imported from a dependent project, and some of which are local. When I have a failing test in the dependent project, I can click the error, and be transported to the line that's breaking. This isn't working for the local tests. It just takes me to the file, but not the breaking line.
Does anyone know if there is something special I need to do in my unit tests, or configuration of XCode, to get jumping to the broken test working?
(I'm on XCode 4.6.2)
It's not you. Xcode 4 doesn't correctly interpret relative paths like proj1/foo/../../proj2/bar/file.m for unit test failures.
I would like to create a library for iOS applications which uses UIKit. Furthermore I would like to create unit tests for this library. Unfortunately my tests do not work because of UIKit ([UIFont systemFontOfSize:12.0] to be precise).
According to Apple's Unit Testing Guide there are two types of test cases: logic tests and application tests. Application tests seem to be the correct type for tests involving UIKit related stuff but I did not find out about how to set up application tests for libraries. Has anybody ever had the same problem and was able to solve it?
Thanks a lot!
I found a solution to this. You must add a new target to your project that is simply an empty application. Then use that application as your test host following the instructions for doing this with a regular application like here:
Why does instantiating a UIFont in an iphone unit test cause a crash?