UITest does not work within Framework - ios

I am creating a framework for an iOS and my framework contains UI(Visual Presentation) as well now I want to write XCTest for my framework and I am able write and run the unit Test as we do within application but I am not able run UITest within the framework.
Could anyone help me with this?
your help will be appreciated.

UI tests for iOS that use XCTest
run in a separate process
require a host application that runs on the simulator
If you want to UI test your framework, I would create a separate iOS app target that includes and consumes your framework. Then you can create a UI Tests target for this demo application which will assert the framework behavior.

Related

How do you test an iOS framework

I am developing an iOS framework. My question is how do I test it in a dummy app. Ideally in the same project window
Technically you have to split into two scenarios.
Your framework contains functionality only.
In that case I suggest to add a unit test target and test your framework by writing unit tests.
Your framework contains a ui component.
In that case I suggest to add an application target and name it ExampleApp or something like that. In that app you can implement a visual example.
Both scenarios are used in open source GitHub repositories.

xCode - how to link dynamic framework from workspace

What is the proper way to link a dynamic framework which lives in the same workspace like the app?
I have a problem when adding the framework from the products folder to the App's "Embedded Binaries" section - because the added framework may be built for simulator and the app builds against iphoneos. I can not add both, can I?
I want to achieve that when my app builds, the framework is built too and I can work the changes immediately instead of doing some cumbersome update via Carthage or something link that.
EDIT: http://netsplit.com/xcode-two-apps-with-a-shared-private-framework-in-a-workspace This blog post describes exactly what i want to do - but this does not work since i want to develop on simulator and iphone (it would require a fat framework). Or did I miss something.
Although is possible to develop main app and framework and doing integration test in the same time from many workspaces, at same point becomes a slow-ish and not scalable development process.
So I suggest you to make a sample app in the workspace of your framework and develop and test your features directly from there. Once your framework is quite stable you release it and you integrate it with your main app.

Unit Testing Issue in Xcode

I have recently integrated XCTest into my project. It works fine when I run test cases using the play button in source editor or Using the play button in test navigator. My problem is, when I use the Test Button (The Spanner like symbol) in the ToolBar I am getting compilation errors.I already have integrated pods in my project and there is a static library created by me as well.
Note : During thorough checking I figure out all the compilation errors coming in the static library created by myself.The error count is too large so compiler shows "too much error" message
Is there any additional setup needed for including the static library into tests?
This issue arise only in case of testing I can succesfuly build and run the project
Thanks
Test Succeeded Here
Compilation Error Here
Try doing a clean build to see if xcode hasn't cached anything when you try to do a full test.
Got the solution finally, the issue is because of test target added as part of my custom library. When I try to run the test from toolbar xcode try to run all the unit test targets (My main project's test and my custom library's test case ). Library's test case can't run independently because it has some coupling with main project. Remove the test target and run test cases everything perfect.

How to run iOS unit tests with cocoapods that include UI references?

I'm trying to run unit tests on my iOS library that includes cocoapod dependencies. The main library target builds fine, but I get this error when running unit tests:
Unknown Device Type. Using UIUserInterfaceIdiomPhone based on screen size
I believe this is because one of my libraries is running UI tests and that the simulator is not capable of handling them. The crash actually originates from this line of code in one of the pods:
[appearance setItemFont:[UIFont boldSystemFontOfSize:14]];
So how can I exclude a pod from testing so that I can run basic logic tests on my classes that have nothing to do with UI?
It sounds like you want to exclude a Pod from your testing target? This is outlined in the Podfile guide.

How to test an iOS Framework

I need to test an iOS Framework. I do not wish to test the UI. Is there any way to test just the Framework which would be used in the main Project?
If you just plan to test logical stuff, you can create new Unittest target for framework by using XCTest.framework. It is available in Xcode 5 and above. There are also third-party unittest frameworks. Check this out http://www.raywenderlich.com/3716/unit-testing-tutorial-for-ios-xcode-4-quick-start-guide

Resources