Reputation: 21
I need to pull out all the names of tests methods and classes for some third-party tool. XCode has testplans that show all the tests for selected target. But the source code of these testplans are only some configuration. Is any possibility to pull this list to some separate file?
Upvotes: 2
Views: 676
Reputation: 22385
The most foolproof way I know of is to actually run the tests, then parse the results.
You can run the tests from the command line like this
xcodebuild test -scheme MyTestScheme -workspace MyWorkspace.xcworkspace -destination 'platform=iOS Simulator,name=My Simulator Name' -resultBundlePath /path/where/xcresult/goes
Then use another tool to parse the results into JSON, for example
xcrun xcresulttool get --format json --path /path/where/xcresult/goes
The JSON structure is a little convoluted, but not hard to figure out if you have the tests to compare it with. This is how I wrote my xcresult2junit script for converting to JUnit for Jenkins CI.
Upvotes: 2