单元测试和 TDD、OCUnit 与 Google Tool Box

发布于 2024-08-14 05:23:04 字数 1512 浏览 7 评论 0原文

我正在尝试在 OCUnit 和 Google Tool Box 之间进行选择,您有什么偏好,会推荐其中之一,为什么? 我很想听听您对这两者中任何一个的体验。

我对这两个方法的主要问题是测试方法中崩溃的管理(例如:BAD ACCESS) 他们都无法告诉我事故发生在哪一堂课!

使用 Google Tool Box,我可以看到正在运行哪个测试套件,但看不到测试用例(当你的测试套件有 50 个测试用例时,你应该怎么做?)

使用 OCUnit,我至少可以看到哪个测试套件中的哪个测试用例导致了崩溃。

这是我向 GTB 传达的信息:

Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds

Test Suite 'LogicTests' started at 2009-12-14 18:03:15 +0100

 /Users/admin/Documents/Tests/GTBTest/RunIPhoneUnitTest.sh: line 122:   688    Segmentation fault      "$TARGET_BUILD_DIR/$EXECUTABLE_PATH" -RegisterForSystemEvents

 Command /bin/sh failed with exit code 139

我可以看到是测试套件“LogicTests”引发了崩溃,但仅此而已。

对于 OCunit,这里是相同错误的消息:

Test Suite 'LogicTests' started at 2009-12-14 17:51:26 +0100
Test Case '-[LogicTests testFail]' started.
/Developer/Tools/RunPlatformUnitTests.include: line 415:   536 Segmentation fault      "${THIN_TEST_RIG}" "${OTHER_TEST_FLAGS}" "${TEST_BUNDLE_PATH}"

至少使用 OCUnit,我可以跟踪正在运行的测试用例并最终对其进行调试(但这可能需要很长时间,没有任何类和行号信息...

)你处理这些问题吗?

提前致谢。

PS:这里是如何重现问题,非常简单:

只需创建一个类,其中的方法在调用时会崩溃(当您进行 TDD 时,这种情况经常发生):

- (void) crashMethod {
 NSMutableArray *crashArray;
 [crashArray addObject:[NSObject new]];
}

然后创建一个调用此方法的测试用例:

- (void) testFail {
    ClassToTest *test = [[ClassToTest alloc] init];
 [test crashMethod];
 [test release];
 }

提前致谢, 文森特

I'm trying to choose between OCUnit and Google Tool Box, do you have any preferences, would recommend one or the other, why ?
I would be very interested to hear about your experiences with any of the 2.

The main problem i have with both of them is the managment of crashes in tested methods (ex: BAD ACCESS)
None of them was able to tell me in what class the crash occured !!!

With Google Tool Box i can see which test suite was being run but not the test case (how are you supposed to do when your test suite has 50 test cases ?)

With OCUnit i can at least see what test case in what test suite caused the crash.

Here is the kind of message i have with GTB :

Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds

Test Suite 'LogicTests' started at 2009-12-14 18:03:15 +0100

 /Users/admin/Documents/Tests/GTBTest/RunIPhoneUnitTest.sh: line 122:   688    Segmentation fault      "$TARGET_BUILD_DIR/$EXECUTABLE_PATH" -RegisterForSystemEvents

 Command /bin/sh failed with exit code 139

I can see that it's it the test suite 'LogicTests' that originated the crash but that's all.

With OCunit here is the message for the same error :

Test Suite 'LogicTests' started at 2009-12-14 17:51:26 +0100
Test Case '-[LogicTests testFail]' started.
/Developer/Tools/RunPlatformUnitTests.include: line 415:   536 Segmentation fault      "${THIN_TEST_RIG}" "${OTHER_TEST_FLAGS}" "${TEST_BUNDLE_PATH}"

At least with OCUnit i can track what test case was being run and eventually debug it (but that could take a very long time without any class and line number info...)

How do you deal with these problems ?

Thanks in advance.

PS: here is how to reproduce the problem, it's very simple :

Just create a class with a method that crashes when it's called (which happens all the time when you're doing TDD) :

- (void) crashMethod {
 NSMutableArray *crashArray;
 [crashArray addObject:[NSObject new]];
}

And then create a test case that calls this methods :

- (void) testFail {
    ClassToTest *test = [[ClassToTest alloc] init];
 [test crashMethod];
 [test release];
 }

Thanks in advance,
Vincent

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拧巴小姐 2024-08-21 05:23:04

我想无论如何我都会选择 GTB。

使用 xCode 3.2 OCUnit 错误和警告不会显示在代码中。
似乎这是一个已知问题:
lhttp://osdir.com/ml/xcode-users/2009- 10/msg00216.html

使用 GTB 可以正常工作。
我不敢相信,但似乎 GTB 比 OCUnit 与新版本的 xCode 集成得更好......

单元测试的调试不需要任何东西,它从一开始就工作得很好。 (使用 xCode 你需要一堆设置:
http://chanson.livejournal.com/119578.html

使用 GTB,您可以运行测试在设备上,并且您有用于 UI 测试的工具(似乎您可以创建一个假的 UIView 层次结构,然后将其与运行时的内容进行比较)。我对 UI 自动测试持怀疑态度(昂贵且难以维护),但这是一个很好的功能!

http://code.google.com/p/google- toolbox-for-mac/wiki/CodeVerificationAndUnitTesting

I think i'll go with GTB anyway..

With xCode 3.2 OCUnit errors and warnings are not showing up inside the code.
Seems it's a know issue :
lhttp://osdir.com/ml/xcode-users/2009-10/msg00216.html

With GTB it works fine.
I cant believe it but it seems GTB is better integrated with newer versions of xCode than OCUnit....

Debugging of unit tests doesn't require anything, it works great from the start. (with xCode you need a bunch of settings :
http://chanson.livejournal.com/119578.html

With GTB you can run your tests on the device and you have tools for UI testing (seems you can create a fake UIView hierarchy and then compare it with what you have at runtime). I'm skeptical about UI automatic testing (expensive and hard to maintain) but that's a nice feature !

http://code.google.com/p/google-toolbox-for-mac/wiki/CodeVerificationAndUnitTesting

神也荒唐 2024-08-21 05:23:04

顺便说一句,Google 工具箱现在会打印测试用例启动消息,以防有人想知道;-)

BTW the Google Toolbox now prints Test case started messages in case anyone was wondering ;-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文