KIF tests are executed in alphabetical order but what if i have more then one file? I want to run all my automation tests in one sequence, can it be done ?
in a single file this holds true:
- (void)testB {} will be the second test
- (void)testA {} will be the first test
- (void)testC {} will be the third test
However, let's say i have MainScreenTest.m and then SecondScreenTest.m and then ThirdScreenTest.m and i run the entire test suite. How do i know which one will run first ? I've tried to run just one file but can multiple work simultaneously ?
KIF will run the files themselves in alphabetical order as well. So it will be like this:
TestFileA
-(void)testA
-(void)testE
-(void)testR
TestFileB
-(void)testB
-(void)testC
-(void)testE
and so on
And you didn't ask this but just in case you need to know: All tests should standalone so that it doesn't matter what order the tests are run in. That is why they are run alphabetically. So for example every test should return to the screen that it was on when it started so that the next test can run from that screen.
In a project of mine there is a log in and then also tab bars. This is how I have things set up (this is sudo code, please do not copy and paste any of it):
TestA
-(void)beforeAll{login, & tapTabBarA} <- This happens once
-(void)beforeEach{ } <- Anything in here would happen before every test
-(void)afterEach{tapTabBarA} <- This happens after every test
-(void)afterAll{logout} <- This happens once
-(void)testSomethingA1
-(void)testSomethingA2
TestB
-(void)beforeAll{login, & tapTabBarB}
-(void)beforeEach{ }
-(void)afterEach{tapTabBarB}
-(void)afterAll{logout}
-(void)testSomethingB1
-(void)testSomethingB2
This way if testSomethingA1 fails, testSomethingA2 will be able to run because it is starting from the correct view (in this case the root view of TabBarA). Similarly if TestA fails TestB will still be run because again even on fail the second run will start at the right location (in this case the log in view controller). Hope this helps!