No. You should write your tests as isolated cases that can be run no independent of each other, no matter the order.
How to set the order sentestkit-test runs?
-
29-06-2022 - |
Pergunta
I am using SenTestKit to test an iOS app. I've split tests into methods which run For example: In
@interface simpleGameTests : SenTestCase
With tests:
- (void)testFindingFacebookFriends
- (void)testRegisterUsernameFromForm
- (void)testStartGame
It seems kind of random which of the tests that run first, second and third. Is it possible in Xcode to set the order which the tests run?
Solução
Outras dicas
Yes, although the accepted answer is idealistically true and your test cases should indeed be isolated you can set the order in actuality you can control the order and sometimes it is preferable to do so. They are executed in alphabetical order, so testACreateAccount
will be executed before testBLoginToAccount
. I use this to generate a password in setUp routine then use that in testACreateAccount
to setup the account and testBLoginToAccount
to test account login using the created one. In this way the test is full and complete (and also no longer strictly a unit test) but it is an invaluable test for my code.