Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to execute tests from command line via xcodebuild

Tags:

I am trying to build and run test cases using command line for iOS test cases. I have given the following command:

xcodebuild -target AppEngineTests -configuration Debug -sdk iphonesimulator TEST_AFTER_BUILD=YES clean build

It builds the app but the testcases are not run.

could someone please help? Thanks

like image 637
Sunny Avatar asked Nov 27 '13 08:11

Sunny


People also ask

What is Xcodebuild?

DESCRIPTION. xcodebuild builds one or more targets contained in an Xcode project, or builds a scheme contained in an Xcode workspace or Xcode project. Usage To build an Xcode project, run xcodebuild from the directory containing your project (i.e. the directory containing the projectname.

What does Xcodebuild clean do?

Clean the Build Folder This will delete all of the products and intermediate files in the build folder. To clean the build folder you can use the shortcut Command+Option+Shift+K or Menu Bar → Product → Hold Option Key → Clean build Folder .

What is Xctestrun file?

A base class for collecting information about a specific execution of a test.

How do I build and run a unit test in xcodebuild?

xcodebuild provides several options for running unit tests. To build and run unit tests from the command line, execute the following command in Terminal: To build unit tests without running them from the command line, execute the following command in Terminal:

Does xcodebuild run tests sequentially or sequentially?

Note: xcodebuild runs your tests sequentially. For instance In Listing 17, xcodebuild will first test iOS in the Simulator before executing it on the iPod touch. How do I implement the Build For Testing and Test Without Building features from the command line?

How do I run a test in Xcode?

The test action is what you use to run tests from a certain scheme in an Xcode project: If your app uses a workspace, perhaps because of CocoaPods, you'll need to pass the -workspace option instead of -project: -workspace MyAwesomeApp.xcworkspace. You can run instruments -s devices to see a list of know devices to use as the -destination option.

Do I need command line tools for Xcode 11?

Command Line Tools Package for Xcode To be able to build and test your project using the terminal window you will need to have the Command Line Tools package installed on your machine. If the machine you want to build and run Xcode tests does already have Xcode 11 installed, then most likely you do already have the command-line tools installed.


1 Answers

I've found the name property to require more specification.

xcodebuild test -workspace #{WORKSPACE_FILE} -scheme #{TEST_SCHEME} -destination 'platform=iOS Simulator,name=iPhone Retina (4-inch),OS=7.0'

Was what finally worked for me. iPhone was limited and/or unpredictable.

As another poster (can't find the citation) mentioned, the 'platform' loosely corresponds to the divider in the target list, 'name' corresponds to the sub-selection, and the OS parameter corresponds to the right side of the chevron in the same list minus 'iOS '.

The documentation is suggestive and sounds authoritative on first glance without actually being full or correct, unfortunately.

Astonishing what a hassle this was. And how well it worked once the right invocation was achieved.

like image 109
tooluser Avatar answered Oct 18 '22 23:10

tooluser