Sunday, December 16, 2018

XCUITesting : Flow of Test execution



In the default case when run tests, XCTest finds all the test classes and, for each class, runs all of its test methods.

There are options available to change specifically what tests XCTest runs. You can disable tests using the test navigator or by editing the scheme. You can also run just one test or a subset of tests in a group using the Run buttons in either the test navigator or the source editor gutter.


For each class, testing starts by running the class setup method. For each test method, a new instance of the class is allocated and its instance setup method executed. After that it runs the test method, and after that the instance teardown method. This sequence repeats for all the test methods in the class. After the last test method teardown in the class has been run, Xcode executes the class teardown method and moves on to the next class. This sequence repeats until all the test methods in all test classes have been run.


One question that came in mind is, how about if we need some state from the previous method execution? Probably, need to call the method from this method under test?

references:
https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/04-writing_tests.html#//apple_ref/doc/uid/TP40014132-CH4-SW33

No comments:

Post a Comment