使用xctool运行单个KIWI规范 [英] Running a single KIWI spec with xctool
问题描述
任何人都可以成功地将KW_SPEC变量传递给xctool.我正在尝试使用
Has anyone been able to successfully pass the KW_SPEC variable to xctool. I'm trying to run a single KIWI spec by using https://github.com/kiwi-bdd/Kiwi/wiki/Kiwi-FAQ#q-how-do-i-run-a-single-spec-describecontextit.
我可以使用xctool成功地运行所有测试,但是它似乎没有获得KW_SPEC值.我已经在许多不同的地方用命令行尝试过了,但是没有运气.
I can run all the tests successfully with xctool but it doesn't seem to pick up the KW_SPEC value. I've tried it in a lot of different places with the command line but no luck.
例如:
xctool -destination 'platform=iOS Simulator,name=iPad Retina,OS=latest'
-sdk iphonesimulator -workspace SampleProject.xcworkspace
-scheme SampleProject KW_SPEC=NewAssessmentTests.m:12 test
-only SampleProject_Acceptance_Tests
使用Kiwi v2.3.1和xctool 0.2.3
Using Kiwi v2.3.1 and xctool 0.2.3
干杯, 莫
推荐答案
更新11/03/2015
@OhadSchneider的评论使我意识到KW_SPEC
对我有用,因为我已经在方案的测试配置(Edit scheme->Test->Arguments->Environment variables
)中对其进行了设置.从shell设置变量不起作用,因为该变量仅适用于实际构建,不适用于执行单元测试目标时.
但是,有一种解决方法,可以通过修改方案的测试阶段并添加值为$KW_SPEC
的KW_SPEC
环境变量,在将xcodebuild运行为传递给xcodebuild
命令的值时,它会扩展.原始答案).此后,xcode将正常使用传递的KW_SPEC
变量,xctool仍将跳过的teste标记为失败问题.
Update 11/03/2015
@OhadSchneider's comment made me realise that KW_SPEC
worked for me because I had set it in the test configuration for my scheme (Edit scheme->Test->Arguments->Environment variables
). Setting the variable from shell doesn't work as that variable applies only to the actual build, and not when executing the unit test target.
But there's a workaround to this, by modifying the test phase of your scheme and adding a KW_SPEC
environment variable with the value $KW_SPEC
, this will expand when running xcodebuild to the value passed to the xcodebuild
command (as in my original answer). After this, xcode will will gracefully use the passed KW_SPEC
variable, xctool still has the skipped teste marked as failure issue.
如果要将KW_SPEC作为xctool(或任何* nix工具)的环境变量,则必须将其放在命令之前,否则它将被视为构建设置:
If you want KW_SPEC as an environment variable to xctool (or to any *nix tool), then you have to place it before the command, otherwise it will be considered a build setting:
KW_SPEC=NewAssessmentTests.m:12 xctool
-destination 'platform=iOS Simulator,name=iPad Retina,OS=latest'
-sdk iphonesimulator -workspace SampleProject.xcworkspace
-scheme SampleProject test
-only SampleProject_Acceptance_Tests
但是,这将导致另一个问题:xctool
会将未运行的测试报告为错误,并且即使没有测试失败,也会将测试报告为失败. xcodebuild
不会出现此问题,因为它要么不执行单元测试发现,要么忽略未运行的测试,这是xctool
做不到的事情.
This will however lead to another problem: xctool
will report as errored the tests that don't run, and will report the test as failed, even if no tests have failed. xcodebuild
doesn't have this problem as it either doesn't do unit tests discovery, or ignore tests that didn't run, a thing that xctool
fails to do.
这篇关于使用xctool运行单个KIWI规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!