Set up a test project using XCTest with two targets for iOS and OSX and using common unit tests

I would like to have one project for Unit-testing a library that performs unit tests on Mac OS X and iOS, for two separate test purposes within the same Xcode project. Unit Test files should be split.

It seems that this is impossible, or not intended to work, or otherwise, it encounters an error:

While it is possible to run a full Unit Test for each iOS and Mac OS X (via the Product → Test command), it is not possible to run individual test methods by clicking on a diamond in the gutter:

enter image description here

In doing so, Xcode opens an error sheet saying:

Appointment to run. The 64-bit Mac bit is not suitable for the tests you have chosen to run.

Choose a run location that supports the tests you want to run.

enter image description here

I thought the problem was that in a single project with two goals, the common Unit Test files should be associated with the test objects of iOS and Mac OS X. That is, the “Target Membership” for a specific Unit Test file is set for iOS and the goal of MacOSX.

Running individual tests from diamond in the gutter seems to work only when combining common Unit Test files with only one purpose.

Has anyone been able to get this to work? What will be an alternative solution?

+6
source share
1 answer

This will disappear if you delete all user records for the architecture building option (ARCHS) in your main goal and test goal for each platform. After that, it will only work with the default setting for OSX / IOS.

Please note that when you switch between OSX and IOS schemes, you first need to wait until the pointer is in the trough, and first you will need to run all the tests for the platform. After that, you can at least run one test from the Test Navigator. It seems that Xcode sometimes still has problems displaying the built-in test button of the source code. Although it is possible to run one test.

0
source

Source: https://habr.com/ru/post/954606/


All Articles