Xcode : One test target for multiple app targets
Asked Answered
L

3

40

I am wondering if you can link one Unit Testing bundle to multiple targets. So one can test all the application targets with one Testing bundle.

I have some shared code between all app targets but also some specific calculations based upon which app target is running.

Currently I have to set the Bundle Loader option in the Build Settings to the used application target's .app file if I want to test a different application target.

My question to you all is : can this be done without creating multiple test bundle targets for every app target, and without always changing the Bundle Loader option?

Linearity answered 28/11, 2012 at 7:59 Comment(3)
I've got a similar scenario now, did you get anywhere with this?Tableau
Nope, we just stopped testing. :)Linearity
I think you can create several Schemes and override Bundle Loader there – if my memory serves me right, there was a possibility to override arguments and environment variables for each Scheme and action (Run, Profile, Test) and so on.Mongolia
M
8

You need to:

  • Select the target you want to test
  • Go to Test navigation tab
  • Right-click on test target you want to enable
  • Click on Enable [name_of_your_target]

enter image description here

Morph answered 15/11, 2019 at 16:1 Comment(1)
I could not find this option. But you can find more answers here: #37698139Kohn
W
3

No, at this point you can't. It's like the extensions, you have to create a new one for each project's targets you have.

It's not pretty usefull but if the code differes from one to another target, the tests can fail because of missing code, not failing code.
It's why it's not allowed.

Sorry for the negative answer.

Wholehearted answered 14/6, 2016 at 12:49 Comment(0)
P
0

You can create several test targets - one for each app target, and then simply put all of your actual test source files into a separated group folder, making sure you select all the test targets for each of the files. Described here: https://medium.com/@rijalab/how-to-use-one-test-target-files-for-two-app-targets-in-ios-37df53265a5

Protamine answered 10/10, 2023 at 18:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.