Running Individual Xctest (Ui, Unit) Test Cases for iOS Apps from the Command Line

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

It is now possible with Xcode 8 using the -only-testing parameter with xcodebuild:

xcodebuild test -workspace <path>
-scheme <name>
-destination <specifier>
-only-testing:TestBundle/TestSuite/TestCase

Sample Image

Is it possible to run individual test cases/test classes on the command line with xcode 5?

Not that I know of, and it's not on the man page either. But you have such option in the excellent xctool (-only SomeTestTarget:SomeTestClass/testSomeMethod).

iOS: Run a single unit test from the command line

Try using xctool which can run tests on devices https://github.com/facebook/xctool

Target individual XCTest unit test cases in Xcode 5 to a specific iOS device for a universal app?

To target device specific tests one would need to edit the schemes for a project. Under Product > Scheme > Edit Schemes one can choose to select device specific tests per device.

Scheme Editor

Can you run a specific Xcuitest from the command line?

You should be able to do that with xctool command line tool for running specific test class,

xctool -workspace YourWorkspace.xcworkspace -scheme YourScheme test -only myUITestTarget:UITestClass

You can also use xcodebuild to run the entire test suite as explained here,
https://krausefx.com/blog/run-xcode-7-ui-tests-from-the-command-line

How do I run xctest from the command-line with Xcode 5?

Despite what the usage message says -XCTest is the argument you need:

xctest -XCTest MyAppTests/testExample testbundle.xctest

For a direct invocation of xctest to work you may also need to set DYLD_FRAMEWORK_PATH and DYLD_LIBRARY_PATH to your built products directory. In general you need to use the same arguments and environment as Xcode does, you can see this by putting a breakpoint in one of your tests, running them through Xcode, then printing out the values of arguments and environment for [NSProcessInfo processInfo].

To avoid messing with all that note you can also modify the scheme in Xcode to run only specific tests. Under Product > Scheme > Edit Scheme select the Test action and expand the test bundle. You can use the check boxes to select the tests to run and xcodebuild's test action will then run only these tests.



Related Topics



Leave a reply



Submit