I need to add test cases to an existing project, so I tried adding a new test target via
Even after adding, the target is not getting listed in the test filter bar.
May be because of this issue, Product -> Test
option is diabled in my project.
Also I could see some differnce between the build setting in my project and another sample project I started in Xcode 6.1 in which Product -> Test
option is enabled and everything working fine for Test cases.
Please find the build settings screen shots.
Any help is appreciated.
To add a unit test target to an existing Xcode project, choose File > New > Target. Select your app platform (iOS, macOS, watchOS, tvOS) from the top of the New Target Assistant. Select the Unit Testing Bundle target from the list of targets.
Select your project in Xcode now in the general tab you will be able to see the targets of your project. It usually comprises TestCases or if your app supports today's extension it also appears as a target, these are some usually visible targets in any app.
I had this exact problem. It turns out my existing project was creating my Cocoa Touch Testing Bundle with the .app extension when it should've been a .xctest extension.
You can fix this by going to your test target you created. Build Settings > Wrapper Extension
and changing it from app
to xctest
.
You may have to restart Xcode after this change to select your test target.
UPDATE: I found out the reason the Testing Bundle was becoming a .app
extension in the first place. I had to go to the main project Wrapper Extension
and make sure it was blank instead of .app
. Apparently that was forcing all targets to become .app
extension as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With