红绿灯是SenTestKit的扩展库,通过使用户更易于解析测试输出,使测试输出更加容易理解。
将SenTestLog+RedGreen.{h,m}添加到您的项目的测试目标中。编译。测试。庆祝。
认真地。尽快找到那些通过的测试。是不是很难?
Test Suite '/Users/neil/Code/libs/RedGreen/DerivedData/RedGreen/Build/Products/Debug-iphonesimulator/RedGreenTests.octest(Tests)' started at 2013-05-11 10:32:02 +0000
Test Suite 'RedGreenTests' started at 2013-05-11 10:32:02 +0000
Test Case '-[RedGreenTests testBooleanAssertions]' started.
/Users/neil/Code/libs/RedGreen/RedGreenTests/RedGreenTests.m:15: error: -[RedGreenTests testBooleanAssertions] : "true" should be false. Expected true to be false.
/Users/neil/Code/libs/RedGreen/RedGreenTests/RedGreenTests.m:16: error: -[RedGreenTests testBooleanAssertions] : "false" should be true. Expected false to be true.
Test Case '-[RedGreenTests testBooleanAssertions]' failed (0.000 seconds).
Test Case '-[RedGreenTests testCanIProvideBetterOutput]' started.
Test Case '-[RedGreenTests testCanIProvideBetterOutput]' passed (0.000 seconds).
Test Case '-[RedGreenTests testDidIProvideBetterOutput]' started.
Test Case '-[RedGreenTests testDidIProvideBetterOutput]' passed (0.000 seconds).
Test Case '-[RedGreenTests testEqualityAssertions]' started.
/Users/neil/Code/libs/RedGreen/RedGreenTests/RedGreenTests.m:30: error: -[RedGreenTests testEqualityAssertions] : '(null)' should be equal to 'Invalid user credentials.' Unexpected error messsage.
Test Case '-[RedGreenTests testEqualityAssertions]' failed (0.000 seconds).
Test Case '-[RedGreenTests testEstimatesAreEqual]' started.
Test Case '-[RedGreenTests testEstimatesAreEqual]' passed (0.000 seconds).
Test Case '-[RedGreenTests testFails]' started.
/Users/neil/Code/libs/RedGreen/RedGreenTests/RedGreenTests.m:45: error: -[RedGreenTests testFails] : You deliberately called STFail().
Test Case '-[RedGreenTests testFails]' failed (0.000 seconds).
Test Case '-[RedGreenTests testSenTestLogOutput]' started.
Test Case '-[RedGreenTests testSenTestLogOutput]' passed (0.000 seconds).
Test Case '-[RedGreenTests testSucceeds]' started.
Test Case '-[RedGreenTests testSucceeds]' passed (0.000 seconds).
Test Suite 'RedGreenTests' finished at 2013-05-11 10:32:02 +0000.
Executed 8 tests, with 4 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite '/Users/neil/Code/libs/RedGreen/DerivedData/RedGreen/Build/Products/Debug-iphonesimulator/RedGreenTests.octest(Tests)' finished at 2013-05-11 10:32:02 +0000.
Executed 8 tests, with 4 failures (0 unexpected) in 0.001 (0.002) seconds
红绿灯同样信息现在更易于阅读。再次找到那些通过的测试。是不是容易多了?
Test Suite '/Users/neil/Code/libs/RedGreen/DerivedData/RedGreen/Build/Products/Debug-iphonesimulator/RedGreenTests.octest(Tests)' started at 2013-05-11 10:33:17 +0000
Test Suite 'RedGreenTests' started at 2013-05-11 10:33:17 +0000
FAILED: -[RedGreenTests testBooleanAssertions] (0.00037s)
Line 15: "true" should be false. Expected true to be false.
Line 16: "false" should be true. Expected false to be true.
PASSED: -[RedGreenTests testCanIProvideBetterOutput] (0.00002s)
PASSED: -[RedGreenTests testDidIProvideBetterOutput] (0.00001s)
FAILED: -[RedGreenTests testEqualityAssertions] (0.00010s)
Line 30: '(null)' should be equal to 'Invalid user credentials.' Unexpected error messsage.
PASSED: -[RedGreenTests testEstimatesAreEqual] (0.00005s)
FAILED: -[RedGreenTests testFails] (0.00009s)
Line 45: You deliberately called STFail().
PASSED: -[RedGreenTests testSenTestLogOutput] (0.00002s)
PASSED: -[RedGreenTests testSucceeds] (0.00001s)
Test Suite 'RedGreenTests' finished at 2013-05-11 10:33:17 +0000.
Executed 8 tests, with 4 failures (0 unexpected) in 0.001 (0.001) seconds
Test Suite '/Users/neil/Code/libs/RedGreen/DerivedData/RedGreen/Build/Products/Debug-iphonesimulator/RedGreenTests.octest(Tests)' finished at 2013-05-11 10:33:17 +0000.
Executed 8 tests, with 4 failures (0 unexpected) in 0.001 (0.002) seconds
我们可以做得更好,如果有可能,我们就应该去做。红绿灯支持优秀的XcodeColors插件,这使得视觉上解析测试输出变得非常简单。现在您可以轻松找到那些通过的测试而无需实际阅读任何内容。只需一眼即可。
Test Suite '/Users/neil/Code/libs/RedGreen/DerivedData/RedGreen/Build/Products/Debug-iphonesimulator/RedGreenTests.octest(Tests)' started at 2013-05-11 10:33:17 +0000 Test Suite 'RedGreenTests' started at 2013-05-11 10:33:17 +0000 FAILED: -[RedGreenTests testBooleanAssertions] (0.00037s) Line 15: "true" should be false. Expected true to be false. Line 16: "false" should be true. Expected false to be true. PASSED: -[RedGreenTests testCanIProvideBetterOutput] (0.00002s) PASSED: -[RedGreenTests testDidIProvideBetterOutput] (0.00001s) FAILED: -[RedGreenTests testEqualityAssertions] (0.00010s) Line 30: '(null)' should be equal to 'Invalid user credentials.' Unexpected error messsage. PASSED: -[RedGreenTests testEstimatesAreEqual] (0.00005s) FAILED: -[RedGreenTests testFails] (0.00009s) Line 45: You deliberately called STFail(). PASSED: -[RedGreenTests testSenTestLogOutput] (0.00002s) PASSED: -[RedGreenTests testSucceeds] (0.00001s) Test Suite 'RedGreenTests' finished at 2013-05-11 10:33:17 +0000. Executed 8 tests, with 4 failures (0 unexpected) in 0.001 (0.001) seconds Test Suite '/Users/neil/Code/libs/RedGreen/DerivedData/RedGreen/Build/Products/Debug-iphonesimulator/RedGreenTests.octest(Tests)' finished at 2013-05-11 10:33:17 +0000. Executed 8 tests, with 4 failures (0 unexpected) in 0.001 (0.002) seconds
版权所有 (c) 2013 Neil Cowburn (http://github.com/neilco/)
任何获得本软件及其相关文档文件(以下简称为"软件")副本的个人均可免费使用该软件,不受任何限制地进行处理,包括但不限于使用、复制、修改、合并、发布、分发、再许可、并/或销售软件的副本,并允许获取该软件的个人对此软件进行上述操作,但以下条件必须遵守
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
SOFTWARE 系"现状"提供,不提供任何形式的产品保证,无论是在明示的还是在暗示的,包括但不限于对适销性、针对特定目的的适用性和非侵权的保证。在任何情况下,作者或版权所有者不对因其软件、软件的使用或与本软件或其使用相关的其他活动而产生的任何索赔、损害或其他责任负责,无论是基于合同、侵权或其它原因。