有人可以告诉我这个断言可以优化吗?iOS 中的单元测试让我难以接受。一个关于 NSArray 计数的简单断言不应该这么冗长:
GHAssertEquals([[NSNumber numberWithInt:[caseArray count]] intValue],
[[NSNumber numberWithInt:627] intValue],
@"array count equals");
编辑:下面的建议行
GHAssertEquals([caseArray count], 627, @"array count equals");
产生这个输出:
Reason: Type mismatch -- array count equals
0 CoreFoundation 0x01cfd02e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x0113ae7e objc_exception_throw + 44
2 CoreFoundation 0x01d85fb1 -[NSException raise] + 17
3 Tests 0x00027711 -[GHTestCase failWithException:] + 33
4 Tests 0x0001a0ed -[CaseTest testGetCaseArrayFromJSONArray] + 3293
5 libobjc.A.dylib 0x0114e663 -[NSObject performSelector:] + 62
6 Tests 0x00022e19 +[GHTesting runTestWithTarget:selector:exception:interval:reraiseExceptions:] + 450
7 Tests 0x0001ea90 -[GHTest run:] + 275
8 Tests 0x000211ea -[GHTestGroup _run:] + 696
9 Tests 0x00021513 -[GHTestGroup run:] + 130
10 Tests 0x000211ea -[GHTestGroup _run:] + 696
11 Tests 0x00021513 -[GHTestGroup run:] + 130
12 Tests 0x000239a2 -[GHTestRunner runTests] + 257
13 Tests 0x00023b12 -[GHTestRunner _runInBackground] + 79
14 Foundation 0x00b85805 -[NSThread main] + 76
15 Foundation 0x00b85764 __NSThread__main__ + 1304
16 libsystem_c.dylib 0x983c7557 _pthread_start + 344
17 libsystem_c.dylib 0x983b1cee thread_start + 34
FAIL (0.033s)