开发者

xcode RunUnitTests script in unit test target?

I'm setting up a unit test target for my iOS app (using 4.2 SDK) by following this guide. The guide says that RunUnitTests should get executed via a shell script in the final phase of my target:

Setting the value for Test Host tells the RunUnitTests script (executed during the final build phase) to launch the specified application and inject your test bundle into it

and indeed, the target I created does have a "Run Script" step, but that step is empty. My test case builds correctly, as "compile sources" does contain my test class, but it doesn't appear to be getting run, as I have a test method I think should fail:

- (void)testClick {
    STAssertTrue(NO, @"sample test");
}

which I think should cause xcode to make some noise, but all I get when building my target is "Build Successful". What am I missing in the target setup? Should the "Link Binary With Libraries" and "Run Script" steps of my unit test target be empty? The target is definitely compiling my test cases, but I don't think it knows to link or run the开发者_StackOverflow中文版 script.

in my target setup, I've set the "Bundle Loader" and "Test Host" properties to what I believe is correct, as when they were set incorrectly, the compiler complained.


Paul, try including this code as the script in your empty "Run Script" build phase:

# Run the unit tests in this test bundle.
"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests"

And make sure the shell line reads /bin/sh. I may have this wrong, as it isn't mentioned in this particular guide, but this is how I've been running my unit tests, and it's been working great.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜