How to test an iOS Framework - ios

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

Related

Xcode can't generate code coverage for prebuilt framework

Can anyone help with this problem:
I have an iOS framework A (written in Swift) and be built to A.framwork.
I have an application B, which uses framework A. There is a Unit test target BTests. Now I want to generate code coverage when run BTests, which call some function in framework A. I haven't found any method to support that: the generated Coverage.profdata never contains coverage information for framework A.
Step to reproduce: as the description above.
Create an Xcode project that builds framework A (can be dynamic or static).
Create another Xcode project, which has application B, and test target BTests.
B includes A
Turn on gather code coverage.
Run unit test (BTests).
Check generated Coverage.profdata and see no coverage information for framework A.

UITest does not work within Framework

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.

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.

CocoaPod and Unit Tests for Swift Framework

So I'm having trouble locating the definitive answer after trawling Cocoapods.org
I know Quick and Nimble are used for Unit Tests, at least for objective-C, however when creating a CocoaPod in Swift as a framework, I read somewhere there is only one choice, but what is that choice?
What is THE framework I have to use for my swift,framework cocoa pod to have it count as tested, as it's not XCTest obviously.
For a pure Swift CocoaPod you can use Quick/Nimble or XCTest. I recommend reading the excerpt here from CocoaPods.org in regards to creating a new Swift framework (including unit tests).
https://guides.cocoapods.org/making/using-pod-lib-create.html
I recently created a Swift CocoaPod using the "pod lib create" command and using only XCTest. Using the provided command line approach you can start a new project to include unit tests and a demo app, if desired and all the setup is handled for you. The only configuration I needed was to ensure the pod target had enable_testability = YES so that your unit tests can read your pod classes.

Resources