I am trying to build and run test cases using command line for iOS test cases. I have given the following command:
我正在尝试使用iOS测试用例的命令行来构建和运行测试用例。我给出了以下命令:
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
有人可以帮忙吗?谢谢
5 个解决方案
#1
17
I've found the name
property to require more specification.
我发现name属性需要更多规范。
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.
最终对我有用的是什么。 iPhone是有限的和/或不可预测的。
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 '.
作为另一个提到的海报(找不到引文),'平台'松散地对应于目标列表中的分隔符,'name'对应于子选择,OS参数对应于V形的右侧。相同的列表减去'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.
令人惊讶的是这是多么麻烦。一旦实现正确的调用,它的效果如何。
#2
12
You haven't said what version of Xcode you're using, but since you tagged your question with "xctest" it seems safe to assume you have Xcode 5 or later.
您还没有说过您正在使用的Xcode版本,但是由于您使用“xctest”标记了您的问题,因此假设您拥有Xcode 5或更高版本似乎是安全的。
Xcode 5 significantly enhances the support for running tests in xcodebuild
, via the test
verb. You'll need to specify a scheme and destination instead of a target when using this verb, because it acts just like the Test command in the Xcode IDE.
Xcode 5通过测试动词显着增强了对xcodebuild中运行测试的支持。使用此动词时,您需要指定方案和目标而不是目标,因为它的行为与Xcode IDE中的Test命令相同。
So for example, assuming you have a shared scheme in your project or workspace named AppEngine that has its Test scheme action properly configured, you would be able to just use
因此,例如,假设您的项目或名为AppEngine的工作区中有一个共享方案,其正确配置了Test方案操作,那么您将能够使用
xcodebuild test -scheme AppEngine -destination 'platform=iOS Simulator,name=iPad'
to run all of the unit tests configured for the AppEngine scheme in the iOS Simulator configured as an iPad running the latest iOS. More details on the syntax of the destination specifier are in the xcodebuild
man page. (You can even use it to run tests on attached iOS devices!)
在配置为运行最新iOS的iPad的iOS模拟器中运行为AppEngine方案配置的所有单元测试。有关目标说明符语法的更多详细信息,请参见xcodebuild手册页。 (您甚至可以使用它在连接的iOS设备上运行测试!)
The scripts that were previously been used to run unit tests have been adjusted to refer users to the test
verb instead because with these improvements it's what everyone should be using.
之前用于运行单元测试的脚本已经过调整,以便将用户引用到测试动词,因为通过这些改进,每个人都应该使用它。
#3
1
It should be noted that you can use instruments -s devices
to get a list of all available devices.
应该注意的是,您可以使用instruments -s设备获取所有可用设备的列表。
You should also pass the string as -destination 'platform=iOS Simulator,id=ID_OF_THE_SIMULATOR'
as for some reason, it doesn't like spaces between the key=value pairs.
您还应该将字符串作为-destination'platform = iOS Simulator,id = ID_OF_THE_SIMULATOR'传递,因为它有一些原因,它不喜欢key = value对之间的空格。
#4
0
I had a similar issue with Xcode build. In my case the problem was that I didn't have any tests associated with my scheme.
我有一个与Xcode构建类似的问题。在我的情况下,问题是我没有任何与我的计划相关的测试。
Please see my SO answer (with diagram) here
请在这里查看我的答案(附图)
#5
0
Landed here looking for a resolution for similar xcodebuild error. As as addendum, you can also pass a single key=val to -destination e.g -destination 'platform=iOS'
and xcodebuild will tell you all the alternative available for the scheme.
登陆这里寻找类似xcodebuild错误的解决方案。与附录一样,您也可以将单个键= val传递给-destination,例如-destination'platform = iOS',xcodebuild将告诉您该方案可用的所有替代方案。
λ ~/Development/app-ios/ task/JIOS-400-Earl-Grey-Spike* xcodebuild -workspace app.xcworkspace -scheme app -destination 'platform=iOS' -derivedDataPath "build" build-for-testing
User defaults from command line:
IDEDerivedDataPathOverride = /Users/schoudhary/Development/app-ios/build
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS }
Missing required device specifier option.
The device type “Generic iOS Device” requires that either “name” or “id” be specified.
Please supply either “name” or “id”.
Available destinations for the "App" scheme:
{ platform:iOS Simulator, id:D248DB01-A852-4360-A9C0-2D71AFE478D7, OS:10.3, name:iPad Air }
{ platform:iOS Simulator, id:CE87AF5A-141C-43DA-AE61-AF53593F37F7, OS:10.3, name:iPad Air 2 }
{ platform:iOS Simulator, id:E93B43E4-D24E-4927-B9EE-0375E15DCBD5, OS:10.3, name:iPad Pro (9.7 inch) }
{ platform:iOS Simulator, id:6D71DB17-0FE2-4D5E-BEE6-CC696445BA11, OS:10.3, name:iPad Pro (12.9 inch) }
{ platform:iOS Simulator, id:F7E37EF4-5E72-438A-A286-216C20158B47, OS:10.3, name:iPhone 5 }
{ platform:iOS Simulator, id:24653844-AE99-4B5B-8332-9FFD2208172F, OS:10.3, name:iPhone 5s }
{ platform:iOS Simulator, id:FD2089A4-BF3F-4F98-8E33-B7EFDCFE5B4D, OS:10.3, name:iPhone 6 }
{ platform:iOS Simulator, id:6EF0DFBD-E99E-4EB3-9C51-6E749F41B6E7, OS:10.3, name:iPhone 6 Plus }
{ platform:iOS Simulator, id:846E631C-6285-4B91-9BA6-1AB6E66C88DB, OS:10.3, name:iPhone 6s }
{ platform:iOS Simulator, id:A6943ADC-F6EF-42F6-9958-D966DFC419FC, OS:10.3, name:iPhone 6s Plus }
{ platform:iOS Simulator, id:B41ABED0-7554-438A-97AC-F34943ED4D79, OS:10.3, name:iPhone 7 }
{ platform:iOS Simulator, id:20F1582C-0D19-4F42-9DAD-43138FB923B9, OS:10.3, name:iPhone 7 Plus }
{ platform:iOS Simulator, id:683BB5CA-E0A8-4CE4-B0DD-AED4C4295B90, OS:10.3, name:iPhone SE }
Ineligible destinations for the "App" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
just another useful way to get the right destination.
只是另一种获得正确目的地的有用方法。
#1
17
I've found the name
property to require more specification.
我发现name属性需要更多规范。
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.
最终对我有用的是什么。 iPhone是有限的和/或不可预测的。
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 '.
作为另一个提到的海报(找不到引文),'平台'松散地对应于目标列表中的分隔符,'name'对应于子选择,OS参数对应于V形的右侧。相同的列表减去'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.
令人惊讶的是这是多么麻烦。一旦实现正确的调用,它的效果如何。
#2
12
You haven't said what version of Xcode you're using, but since you tagged your question with "xctest" it seems safe to assume you have Xcode 5 or later.
您还没有说过您正在使用的Xcode版本,但是由于您使用“xctest”标记了您的问题,因此假设您拥有Xcode 5或更高版本似乎是安全的。
Xcode 5 significantly enhances the support for running tests in xcodebuild
, via the test
verb. You'll need to specify a scheme and destination instead of a target when using this verb, because it acts just like the Test command in the Xcode IDE.
Xcode 5通过测试动词显着增强了对xcodebuild中运行测试的支持。使用此动词时,您需要指定方案和目标而不是目标,因为它的行为与Xcode IDE中的Test命令相同。
So for example, assuming you have a shared scheme in your project or workspace named AppEngine that has its Test scheme action properly configured, you would be able to just use
因此,例如,假设您的项目或名为AppEngine的工作区中有一个共享方案,其正确配置了Test方案操作,那么您将能够使用
xcodebuild test -scheme AppEngine -destination 'platform=iOS Simulator,name=iPad'
to run all of the unit tests configured for the AppEngine scheme in the iOS Simulator configured as an iPad running the latest iOS. More details on the syntax of the destination specifier are in the xcodebuild
man page. (You can even use it to run tests on attached iOS devices!)
在配置为运行最新iOS的iPad的iOS模拟器中运行为AppEngine方案配置的所有单元测试。有关目标说明符语法的更多详细信息,请参见xcodebuild手册页。 (您甚至可以使用它在连接的iOS设备上运行测试!)
The scripts that were previously been used to run unit tests have been adjusted to refer users to the test
verb instead because with these improvements it's what everyone should be using.
之前用于运行单元测试的脚本已经过调整,以便将用户引用到测试动词,因为通过这些改进,每个人都应该使用它。
#3
1
It should be noted that you can use instruments -s devices
to get a list of all available devices.
应该注意的是,您可以使用instruments -s设备获取所有可用设备的列表。
You should also pass the string as -destination 'platform=iOS Simulator,id=ID_OF_THE_SIMULATOR'
as for some reason, it doesn't like spaces between the key=value pairs.
您还应该将字符串作为-destination'platform = iOS Simulator,id = ID_OF_THE_SIMULATOR'传递,因为它有一些原因,它不喜欢key = value对之间的空格。
#4
0
I had a similar issue with Xcode build. In my case the problem was that I didn't have any tests associated with my scheme.
我有一个与Xcode构建类似的问题。在我的情况下,问题是我没有任何与我的计划相关的测试。
Please see my SO answer (with diagram) here
请在这里查看我的答案(附图)
#5
0
Landed here looking for a resolution for similar xcodebuild error. As as addendum, you can also pass a single key=val to -destination e.g -destination 'platform=iOS'
and xcodebuild will tell you all the alternative available for the scheme.
登陆这里寻找类似xcodebuild错误的解决方案。与附录一样,您也可以将单个键= val传递给-destination,例如-destination'platform = iOS',xcodebuild将告诉您该方案可用的所有替代方案。
λ ~/Development/app-ios/ task/JIOS-400-Earl-Grey-Spike* xcodebuild -workspace app.xcworkspace -scheme app -destination 'platform=iOS' -derivedDataPath "build" build-for-testing
User defaults from command line:
IDEDerivedDataPathOverride = /Users/schoudhary/Development/app-ios/build
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS }
Missing required device specifier option.
The device type “Generic iOS Device” requires that either “name” or “id” be specified.
Please supply either “name” or “id”.
Available destinations for the "App" scheme:
{ platform:iOS Simulator, id:D248DB01-A852-4360-A9C0-2D71AFE478D7, OS:10.3, name:iPad Air }
{ platform:iOS Simulator, id:CE87AF5A-141C-43DA-AE61-AF53593F37F7, OS:10.3, name:iPad Air 2 }
{ platform:iOS Simulator, id:E93B43E4-D24E-4927-B9EE-0375E15DCBD5, OS:10.3, name:iPad Pro (9.7 inch) }
{ platform:iOS Simulator, id:6D71DB17-0FE2-4D5E-BEE6-CC696445BA11, OS:10.3, name:iPad Pro (12.9 inch) }
{ platform:iOS Simulator, id:F7E37EF4-5E72-438A-A286-216C20158B47, OS:10.3, name:iPhone 5 }
{ platform:iOS Simulator, id:24653844-AE99-4B5B-8332-9FFD2208172F, OS:10.3, name:iPhone 5s }
{ platform:iOS Simulator, id:FD2089A4-BF3F-4F98-8E33-B7EFDCFE5B4D, OS:10.3, name:iPhone 6 }
{ platform:iOS Simulator, id:6EF0DFBD-E99E-4EB3-9C51-6E749F41B6E7, OS:10.3, name:iPhone 6 Plus }
{ platform:iOS Simulator, id:846E631C-6285-4B91-9BA6-1AB6E66C88DB, OS:10.3, name:iPhone 6s }
{ platform:iOS Simulator, id:A6943ADC-F6EF-42F6-9958-D966DFC419FC, OS:10.3, name:iPhone 6s Plus }
{ platform:iOS Simulator, id:B41ABED0-7554-438A-97AC-F34943ED4D79, OS:10.3, name:iPhone 7 }
{ platform:iOS Simulator, id:20F1582C-0D19-4F42-9DAD-43138FB923B9, OS:10.3, name:iPhone 7 Plus }
{ platform:iOS Simulator, id:683BB5CA-E0A8-4CE4-B0DD-AED4C4295B90, OS:10.3, name:iPhone SE }
Ineligible destinations for the "App" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
just another useful way to get the right destination.
只是另一种获得正确目的地的有用方法。