在设备上运行 OCUnit 应用程序测试套件时偶尔出现错误

发布于 2024-10-11 18:41:56 字数 3261 浏览 4 评论 0原文

运行应用程序测试(即在设备上)时,我的 OCUnit 测试套件遇到一些问题。有时,我会收到一个棘手的错误,该错误似乎是从 OCUnit 类引发的。我一直在尝试查看添加到测试套件中的文件,但无法理解它。

在设置测试目标时,我遵循了 Apple 文档并查看了其他教程,从而产生了以下目标(和缩进的依赖项):

LogicTests

MyApp 逻辑测试

应用测试 我的应用程序 我的

应用程序测试 ApplicationTests

最后一个(MyAppTesting)是我在设备上运行以启动测试套件的测试。

正如所提到的,测试无法启动,有时会在控制台中抛出以下输出:

2010-11-17 12:02:48.537 VCCTesting[12018:307] *** Assertion failure in -[SenTestClassEnumerator init], /SourceCache/OCUnit/OCUnit-1685/SourceCode/SenTestingKit/SenTestClassEnumerator.m:137

2010-11-17 12:02:48.556 VCCTesting[12018:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'objc_getClassList returned more classes than it should have.'
*** Call stack at first throw:
(
0   CoreFoundation                      0x30897ed3 __exceptionPreprocess + 114
1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
2   CoreFoundation                      0x30897d15 +[NSException raise:format:arguments:] + 68
3   Foundation                          0x349f932f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4   SenTestingKit                       0x20107c29 -[SenTestClassEnumerator init] + 292
5   SenTestingKit                       0x201079fd +[SenTestClassEnumerator classEnumerator] + 24
6   SenTestingKit                       0x2010777d +[NSObject(SenTestRuntimeUtilities) senAllSubclasses] + 92
7   SenTestingKit                       0x201067b5 +[SenTestSuite updateCache] + 28
8   SenTestingKit                       0x20106753 +[SenTestSuite suiteForBundleCache] + 54
9   SenTestingKit                       0x201065db +[SenTestSuite structuredTests] + 14
10  SenTestingKit                       0x201065a1 +[SenTestSuite allTests] + 40
11  SenTestingKit                       0x20106573 +[SenTestSuite defaultTestSuite] + 14
12  SenTestingKit                       0x201057a3 +[SenTestProbe specifiedTestSuite] + 106
13  SenTestingKit                       0x20105d83 +[SenTestProbe runTests:] + 94
14  Foundation                          0x349c7e8d __NSFireDelayedPerform + 368
15  CoreFoundation                      0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
16  CoreFoundation                      0x3084e2ad __CFRunLoopDoTimer + 860
17  CoreFoundation                      0x3081f7a5 __CFRunLoopRun + 1088
18  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
19  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
20  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
21  GraphicsServices                    0x31e4469f GSEventRun + 62
22  UIKit                               0x31e51123 -[UIApplication _run] + 402
23  UIKit                               0x31e4f12f UIApplicationMain + 670
24  VCCTesting                          0x000234ff main + 70
25  VCCTesting                          0x00002538 start + 40
)
terminate called after throwing an instance of 'NSException'

有人知道可能出了什么问题吗?

感谢您的任何帮助, 克里

斯托弗我已将其发布在应用程序开发论坛上,但还没有任何运气: https:// /devforums.apple.com/message/333890

I'm having some problems with my OCUnit test suite, when running application tests (i.e. on the device). Occasionally, I get a tricky error that seems to be thrown from the OCUnit classes. I've been trying to look through the files added to the test suites, but can't get my head around it.

I've followed the Apple documentation and looked at other tutorials when setting up my test targets, resulting in the following targets (and indented dependencies):

LogicTests

MyApp
LogicTests

ApplicationTests
MyApp

MyAppTesting
ApplicationTests

The last (MyAppTesting) is the one I run on the device to start the test suite.

And as mentioned, the tests fail to start sometimes throwing me the following output in the console:

2010-11-17 12:02:48.537 VCCTesting[12018:307] *** Assertion failure in -[SenTestClassEnumerator init], /SourceCache/OCUnit/OCUnit-1685/SourceCode/SenTestingKit/SenTestClassEnumerator.m:137

2010-11-17 12:02:48.556 VCCTesting[12018:307] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'objc_getClassList returned more classes than it should have.'
*** Call stack at first throw:
(
0   CoreFoundation                      0x30897ed3 __exceptionPreprocess + 114
1   libobjc.A.dylib                     0x3002f811 objc_exception_throw + 24
2   CoreFoundation                      0x30897d15 +[NSException raise:format:arguments:] + 68
3   Foundation                          0x349f932f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4   SenTestingKit                       0x20107c29 -[SenTestClassEnumerator init] + 292
5   SenTestingKit                       0x201079fd +[SenTestClassEnumerator classEnumerator] + 24
6   SenTestingKit                       0x2010777d +[NSObject(SenTestRuntimeUtilities) senAllSubclasses] + 92
7   SenTestingKit                       0x201067b5 +[SenTestSuite updateCache] + 28
8   SenTestingKit                       0x20106753 +[SenTestSuite suiteForBundleCache] + 54
9   SenTestingKit                       0x201065db +[SenTestSuite structuredTests] + 14
10  SenTestingKit                       0x201065a1 +[SenTestSuite allTests] + 40
11  SenTestingKit                       0x20106573 +[SenTestSuite defaultTestSuite] + 14
12  SenTestingKit                       0x201057a3 +[SenTestProbe specifiedTestSuite] + 106
13  SenTestingKit                       0x20105d83 +[SenTestProbe runTests:] + 94
14  Foundation                          0x349c7e8d __NSFireDelayedPerform + 368
15  CoreFoundation                      0x3084e7fb __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
16  CoreFoundation                      0x3084e2ad __CFRunLoopDoTimer + 860
17  CoreFoundation                      0x3081f7a5 __CFRunLoopRun + 1088
18  CoreFoundation                      0x3081f277 CFRunLoopRunSpecific + 230
19  CoreFoundation                      0x3081f17f CFRunLoopRunInMode + 58
20  GraphicsServices                    0x31e445f3 GSEventRunModal + 114
21  GraphicsServices                    0x31e4469f GSEventRun + 62
22  UIKit                               0x31e51123 -[UIApplication _run] + 402
23  UIKit                               0x31e4f12f UIApplicationMain + 670
24  VCCTesting                          0x000234ff main + 70
25  VCCTesting                          0x00002538 start + 40
)
terminate called after throwing an instance of 'NSException'

Does anyone know what could be wrong?

Thankful for any help,
Kristofer

P.S. I've posted this on the App dev forums, but haven't had any luck with it yet: https://devforums.apple.com/message/333890

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

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

发布评论

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

评论(4

白况 2024-10-18 18:41:56

你有 NSZombieEnabled 吗?当我在单元测试启动目标的参数中将 NSZombieEnabled 设置为 YES 时,我遇到了这个问题。我已经尝试了一切(清理/退出 XCode/休息模拟器内容)。
到目前为止唯一的解决方案是在我的单元测试启动中禁用僵尸

Do you have NSZombieEnabled? I had this issue when I had NSZombieEnabled set to YES in my arguments for my unit test launch target. I've tried everything (cleaning/quitting XCode/restting simulator content).
The only solution so far was to disable zombie in my unit test launch

邮友 2024-10-18 18:41:56

我想我刚刚弄清楚为什么我也遇到了这个错误 - 也许同样的事情也发生在你身上:

我设置了两种产品,一种用于内部 Beta 测试(带有首选项窗格),另一种用于应用程序商店发布。两个产品目标均使用相同的产品名称(构建设置中的 PRODUCT_NAME)进行设置。

这在 XCode 3.x 中工作得很好,但每次我构建 beta 产品时,XCode 4 都会以某种方式尝试构建商店产品。我认为这是由于 XCode 放置其派生文件的位置发生了变化 - XCode 4 将测试版和存储产品存储在同一路径中,因此当构建测试版产品时,存储输出文件发生了更改并且需要重新构建。 ..

无论如何...更改测试版产品名称已修复暂时修复问题...我还更改了Info.plist中的捆绑包标识符,因此这两个产品有不同的标识符。现在,当我构建一个产品时,另一个产品不会同时构建,但在测试运行时我仍然会崩溃:-(

我现在唯一的想法是完全从新创建项目,复制设置和查看 XCode 4 是否做了一些不同的事情,然后向 Apple 提交支持事件...

干杯,

Adam。

I think I've just figured out why I was getting this error as well -- perhaps the same thing is happening to you:

I have two products set up, one for internal beta testing (complete with a preference pane) and one for app store release. Both product targets were set up with the same Product Name (PRODUCT_NAME in build settings).

This worked fine in XCode 3.x, but XCode 4 was somehow trying to build the store product each time I built the beta product. I think this is due to the change in where XCode puts its derived files -- XCode 4 was storing the beta and store products at the same path, so when the beta product was built, the store output file changed and needed to be rebuilt...

Anyway... changing the beta Product Name has fixed temporarily fixed the issue... I've also changed the bundle identifier in the Info.plist so the two products have different identifiers. Now when I build one product, the other doesn't get built at the same time, but I still get the crash when the tests run :-(

My only idea now is to totally recreate the project from fresh, copying across the settings and the files to see if XCode 4 does something different. That and filing a support incident with Apple...

Cheers,

Adam

待"谢繁草 2024-10-18 18:41:56

我还不是 100% 确定,但似乎可以通过为每个测试目标创建不同的方案来解决这个问题。
今天下午我经常遇到这个错误,但在我为不同的测试目标创建单独的方案后,这个错误已经有一段时间没有发生了。

I am not 100% sure yet, but it seems this issue can be solved by creating different scheme for each test target.
I had this error a lot this afternoon but it hasn't happened for awhile after I created separate schemes for different test targets.

油焖大侠 2024-10-18 18:41:56

仅供任何可能像我一样遇到此问题的人使用:

KIFTester 已加载
-[SenTestClassEnumerator init]、/SourceCache/OCUnit/OCUnit-5315/SourceCode/SenTestingKit/SenTestClassEnumerator.m:136 中断言失败
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“objc_getClassList 返回的类多于应有的类。”

问题原来是GoogleAnalytics 3.0
更新到 3.0.3 但这些库仍然存在同样的问题
libGoogleAnalytics_debug.a
libGoogleAnalyticsServices.a

为了解决这个问题,我只是不包含它们进行测试。

Just for anyone that might run into this issue like I have:

KIFTester loaded
Assertion failure in -[SenTestClassEnumerator init], /SourceCache/OCUnit/OCUnit-5315/SourceCode/SenTestingKit/SenTestClassEnumerator.m:136
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'objc_getClassList returned more classes than it should have.'

The problem turned out to be GoogleAnalytics 3.0
Updated to 3.0.3 but still the same problem with either of these libraries
libGoogleAnalytics_debug.a
libGoogleAnalyticsServices.a

To go around it I just don't include them for testing.

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