Running individual XCTest (UI, Unit) test cases for iOS apps from the command line

后端 未结 5 1668
后悔当初
后悔当初 2020-12-02 20:44

Is it possible to run individual test cases, or individual test suites, from an iOS app test target, instead of all the test cases, from a command line interface?

Yo

5条回答
  •  醉话见心
    2020-12-02 20:53

    I was in similar situation as you and have built a python script that triggers the set of test case/s that i want. Its a little bit elaborate process but works for me and has been very useful over time in implementing DataProvider methods, Rerunning of failed test cases and other customizations I required.

    Some relevant steps for what you want to achieve.

    1. Override testInvocations method present in XCTestCase to do below steps
      • In this method I read Environment Variable XXXX.
      • This environment variable is basically a comma separated test case method names.
      • Now create NSInvocations for each test method that you want to trigger.
      • Return array of Invocations.
    2. How to pass Environment Variable?
      • In scheme add an environment variable named XXXX.
      • Scheme files are standard xml files, write a script that modifies the scheme file to contain the Comma separated values in environment variable.

    If you require more info add a comment I will reply to it.

提交回复
热议问题