Lets say I have a pod DevelopmentPod.
In the podspec for this pod, i have added a test_spec as follows -
s.test_spec 'UnitTests' do |test_spec|
test_spec.source_files = 'UnitTests/**/*.{h,m,swift}'
test_spec.ios.resources = ['UnitTests/**/*.{json}']
end
In the Podfile of my project, I have added the pod as follows -
pod 'DevelopmentPod', :path => '<location>', :testspecs => ['UnitTests']
After running pod install, I see that a new target DevelopmentPods-Unit-Tests has been created and using the new scheme in Manage Schemes, I can execute the test cases comfortably.
To integrate this scheme in Jenkins, I will need separate job for this. And I have multiple development pods, which means multiple jobs. Also then will have to consolidate the test case execution data from different jobs. And we can not deterministically say that the code tested by these individual jobs is same as that of the actual build.
What is the best way to solve this problem?
I can easily move all unit tests from different pods to my main app and create a unit test target for the same (which solves the Jenkins job issue too) but then my main app will get cluttered with a lot of unit test code it does not require at all. I would like to keep a pod specific unit test in the pod itself.
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.
Unit testing is a software development process in which the smallest testable parts of an application, called units, are individually and independently scrutinized for proper operation. This testing methodology is done during the development process by the software developers and sometimes QA staff.
Once you have the target you need to edit your scheme to make it run the tests!
Then set it to be tested (by adding it to the +)
Also it is added automatically to the build
And its done! :D
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