How to list all test cases using xcodebuild without running?

Viewed 1881

Using xcodebuild I can run a specific test or group of tests. But is there a way to list all tests without running them, using xcodebuild or any other tool that comes with xcode? Facebook's xctool can do this but I hope to not take dependency on third party tools.

2 Answers

You can get the test names by using "strings". it's not an xcode command, but is normally available on the mac. Run "strings" on the following file and grep whatever marks your tests. in my case, all tests start with "test_":

strings <Tests-Target>-Runner.app/PlugIns/<Tests-Target>.xctest/<Tests-Target>|grep "test_"

an easy way to find this file is by running:

grep -r <single test name> <derived data folder for your project>
Related