What do these Xcode 5.1 Test Navigator icons mean? - xcode

I've created some unit tests in my Xcode 5.1.1 project. I can understand that the "t" in these icons means "test":
—but what does "rT" mean?

The standard way to do things in SenTestingKit/OCUnit/XCTest is to declare your tests in code. If you do, Xcode will discover them statically (ie. not at runtime) using the index. Once Xcode these tests are discovered, they show up in the test navigator with a "T" icon. So far so good.
Now, the SenTestingKit/OCUnit/XCTest frameworks also allow you to create tests on the fly at runtime. Some of our users make creative user of this capability, perhaps to wrap an external testing system or to create tests to represent a dynamic set of data. Xcode cannot discover these tests statically, and only find out about their existence when they are returning resutls during a test run. When discovered, they will show up in the test navigator with a "RT" icon. "RT" being short for "runtime discovered tests".
Finally. If there's anything wrong / unusual about your project that prevents indexing from completing or from properly parsing your test classes, then your tests wouldn't be statically discovered. You may still successfully build and run them, in which case Xcode would end up treating them as runtime discovered tests, and give them the "RT" icon.
Found that here:XCode 5 Testing symbol "rT" means what?
You can also check Apple's information on this:https://developer.apple.com/library/ios/recipes/xcode_help-test_navigator/Recipe.html

Related

Xcode 7: Can't create a Swift command line tool with a unit test target

Oh, Xcode!
I'm stymied. If I create a Mac OS Cocoa app, I get a unit test target for free. But I want to write a command line tool (or even a library that I can link into a command line tool) and write some unit tests against it. I'll be darned if I can figure it out.
I've gotten far enough that I have a command line target, and a test target. I can "#testable import" my commnd line module and use the code in the test code with no errors in Xcode. However, as soon as I try to run my test (Cmd-U), I get a link error. None of the classes in the main module can be linked. What?
I've been messing with this for hours, and the Great Google has been no help. (I'm using Xcode 7, and Xcode 6 seems very different.) Can anyone help me?
Thanks.
So far the only solution I've found for this problem is to manually add all the files containing code that you want to test to unit test target manually:
This is something you wouldn't do when testing an application target. I think the fact that the command line target cannot be selected as the test host for a unit test target might be related with this issue:
Another option you have, which might require a bit more work, is to define all your logic into a Framework, and write the command line app as a consumer of the APIs it provides.
This way you can easily unit test the framework the usual way, and then write integration tests for the command line app in the form of scripts that call it and assert the results.
After struggling with this here is the solution that worked for me:
Step 1: Add a testing bundle. Editor > Add Target, Cocoa Testing Bundle
Step 2: Edit the scheme. Product > Scheme > Edit Scheme. Select Test, click +. Under “Choose targets to test as part of this scheme”, select your test target.
Step 3: Try with you simple test
There are cases when adding the same file to both utility and the test target is not possible (some kind of loops resulting in redefinitions).
However, it's possible to create an additional application target, add all files of the utility except for main.swift to the app, and then use this app as a hosting app for the tests (and also enable "Allow testing Host Application APIs checkbox).

Swift: App Installation Failed Could Not Inspect The Application Package (When Using Frameworks with XCode 6)

I'm having difficulties running a compiled app on an iPhone 6 (iOS8). It works fine in the simulator.
I get this error message:
App installation failed
Could not inspect the application package
Originally there were error messages - such as the one here but I fixed this temporarily by moving the output into the correct location. However even though all of the libraries are being codesign'ed correctly and are now found I am unable to use the app on my device.
There seems to be no further error messages and therefore no way of debugging anything. How exactly do normal iOS developers debug problems which give no error messages?
I guess the underlying problem is that my project is getting quite complex, there are a lot of moving pieces: a few cocoapods, Alamofire, ReactiveCocoa, and Moya.
I have a few general questions:
Where can I find information that documents the use of frameworks in XCode 6?
What is the difference between "Build Phases -> Link Binary With Libraries", "Build Phases -> Copy Files", "General -> Embedded Binaries" and "General -> Linked Frameworks and Libraries"?
Everything is compiling completely fine for the simulator, including the cocoapods, but I note that there are libPod.a files and wonder whether they need to be compiled into the app?
Mostly I am hoping to find some way of finding out why the application package can't be inspected. Surely whatever software that inspects this must be able to be debugged?!!
Edit:
For the record, (1) there is no file called Resources in the root folder as I get nothing back when I do this "find . -name Resources" so it cannot be that issue, (2) I have run "Product -> Clean" and then tried to build again and this does not solve the problem either, (3) the Info.plist does contain a CFBundleName which is set to "${PRODUCT_NAME}" currently (which I believe is set elsewhere.)
I managed to fix this. I am not sure exactly what the solution was, but effectively what I did was to remove all of the cocoapods, detach all of the extra projects that were being used to compile frameworks, and then completely clean the build folder (by holding Alt while going to Product > Clean.)
I then added each of the frameworks back and made sure that each of them would compile.
I checked the build output and near the bottom of each I was able to find the location in which the frameworks were being built.
I then went back to the parent app, and was able to change the framework search paths to include the folders that the frameworks were being built in.
I may have changed a couple of other paths, too, though I cannot remember completely.
I think that basically the issue was a combination of (1) a very dirty build path, (2) leftover files and bad configuration causing issues, (3) frameworks being built in the wrong location.
check your "Copy Bundle Resources",delete info.plist if it contained.
It's work for me in Xcode 6.4

Adding compile sources to Xcode Unit Tests (Application vs Logic)

It seems that Logic tests require that I add application files (.m and .h) to the compile target of the test along with the test .m files. I think that this is because Application tests actually load the app side by side with the tests but I am not sure.
Is the bundle loader 'the difference' between Application and Logic tests? I am not talking about why to use them but the distinction between how they work and what they do.
Here you can find a nice description of the tests, with what they do and how they differ. Also, in the next section here, you can read about how to set them up, which reveals the technical differences between them. As you suggested, loading the app bundle seems to make the difference.
Edit: Seems that the links above no longer work, I found a legacy document here: https://developer.apple.com/legacy/library/documentation/DeveloperTools/Conceptual/UnitTesting/UnitTesting.pdf

How do I add a target to a test scheme?

I have configured unit testing for a project, and I need to use the classes that are in the run scheme also in the test scheme.
This because if I try to use a class that I use in the run scheme, I get a linker error, the linker does not recognize that (user defined) class.
I called the test bundle "TestBundle", I am able to test the application unless I use other classes. This is what I see when I try to edit the test scheme:
It seems like there isn't a place for adding another target, how do I do that?
schemes RUN targets... they don't manage what a target is made up of.
they could also be called 'environments' or 'execution setups' or so :)
targets are managed under your project (when you click onto the blue project icon in the project navigator)
note: I think that apple brought us schemes only to haze us ;D

Do I have to do something to get OCunit tests to compile out of box with XCode 4?

I just installed XCode 4 today (using Apple mac app store), and I created a new Mac OS application, and tried to switch to test mode,and build the test skeleton code it generated for me. It failed here:
In mytests.h:
#import <SenTestingKit/SenTestingKit.h>
The error is:
file://..mytests.h: error: Lexical or Preprocessor Issue: 'SenTestingKit/SenTestingKit.h' file not found
Now, when I use locate from the terminal to find SenTestingKit.h, I notice it exists under the /Developer-old/Library/Frameworks folder (which is what XCode 4 installer renamed my /Developer folder to). There is no new /Developer/Library/Frameworks. And I can't seem to find SenTestingKit.framework on my disk, other than the developer-old one.
What's up? It seems SenTestingKit.framework is not shipped with XCode 4.
Update:
Furthermore, When I copy my old SenTestingKit framework from XCode 3 into /Developer/Library/Frameworks, it sort of builds, but it doesn't work the way I would expect. The dummy test is designed to just fail, but when I "run test", I just get the normal cocoa app document window opening, and no indication that my test has failed (as I intend it to do).
This is pretty bad. I can't get a Unit test to FAIL. That's not the usual situation for me, you understand.
You may find that the reason for this is because you've installed Xcode 4 into a directory such as /Xcode 4.x/ or similar. The space is causing the problem because the -I paths are "Xcode" and "4.x/Library/Frameworks".
To fix this, what you need to do is select your test target, and under its build settings go and find the Framework Search Path, and put quotes around the two arguments, so you have:
"$(SDKROOT)/Developer/Library/Frameworks" and "$(DEVELOPER_LIBRARY_DIR)/Frameworks"
Then you default tests will compile, link and fail.
You will maybe need to import the framework into your project. Otherwise, the header file won't be recognize.
If you can't see the framework you're looking for, you can adjust the framework look paths in your project's build settings.
When you're building unit tests in the same project as you main code, make sure that XCode 4 didn't automatically connect you mytests.m file into the "Compile Sources" section of your main code.
For example, if you have two targets in our project:
MyProject
MyProjectTests
Check the Build Phases for MyProject to see if XCode added mytests.m into the "Compile Sources" accordion. This will cause your builds to fail because SenTest isn't included in the main project.

Resources