xctestcase

Unable To Run Unit Tests in Xcode 11: The run destination * is not valid for tests you have chosen to perform

主宰稳场 提交于 2019-12-01 15:06:15
问题 Pretty sure my tests were running fine before I updated from Xcode 10.3 to Xcode 11. Now when I try to run a test I get the following error. The run destination iPhone 5s is not valid for tests you have chosen to perform. Please select a run destination which supports the tests that you wish to perform. As an experiment, I tried creating a brand new test target and running the example tests that it gives you and the error is the same. I've also tried with different simulators. 回答1: Check your

In XCode 8, what is the way to make test methods run in a particular order within a given XCTestCase class?

﹥>﹥吖頭↗ 提交于 2019-11-30 21:46:58
Prior to XCode 8, you could get your unit tests to run in a particular order by alphabetizing the names of the test methods within a given XCTestCase class (as described in this answer ). E.g., tests would run like: testA, testB, testC, testD, etc. However in XCode 8, this is no longer the case. For example I have test methods named test1, test2, test3, test4, and test4 will run first (see below screenshot). Then I can re-run, and test2 will run first on the next run-through. So... how do I get the tests to run in order now on XCode 8...? So the way I solved this is as follows. Problem recap:

In Xcode 8, what is the way to make test methods run in a particular order within a given XCTestCase class?

南楼画角 提交于 2019-11-30 05:33:04
问题 Prior to Xcode 8, you could get your unit tests to run in a particular order by alphabetizing the names of the test methods within a given XCTestCase class (as described in this answer). E.g., tests would run like: testA, testB, testC, testD, etc. However in Xcode 8, this is no longer the case. For example I have test methods named test1, test2, test3, test4, and test4 will run first (see below screenshot). Then I can re-run, and test2 will run first on the next run-through. So how do I get

How to run one-time setup code before executing any XCTest

a 夏天 提交于 2019-11-30 04:43:54
I have the following problem. I want to execute a piece of code before all test classes are executed. For instance: I don't want my game to use the SoundEngine singleton during executing, but the SilentSoundEngine. I would like to activate the SilentSoundEngine one time not in all tests. All my tests look like this: class TestBasketExcercise : XCTestCase { override func setUp() { SilentSoundEngine.activate () // SoundEngine is a singleton } // The tests } -Edit- Most of the answers are directed at providing custom superclass for the TestCase. I am looking for a more general and cleaner way to

How to run one-time setup code before executing any XCTest

ε祈祈猫儿з 提交于 2019-11-29 01:32:24
问题 I have the following problem. I want to execute a piece of code before all test classes are executed. For instance: I don't want my game to use the SoundEngine singleton during executing, but the SilentSoundEngine. I would like to activate the SilentSoundEngine one time not in all tests. All my tests look like this: class TestBasketExcercise : XCTestCase { override func setUp() { SilentSoundEngine.activate () // SoundEngine is a singleton } // The tests } -Edit- Most of the answers are