我正在尝试使用Specta和Expecta框架在Xcode中对我的代码进行单元测试。我已经在线阅读了很多教程,并相应地设置了我的文件(见下文)。设置完成后,SpecBegin(服务)左侧会出现一个空菱形,当悬停在它上面时会变为播放按钮。
单击播放按钮后,我总是收到以下输出:
Test Suite 'All tests' started at 2014-06-13 16:34:54 +0000
Test Suite 'Handybook_podTests.xctest' started at 2014-06-13 16:34:54 +0000
Test Suite 'Handybook_podTests' started at 2014-06-13 16:34:54 +0000
Test Suite 'Handybook_podTests' finished at 2014-06-13 16:34:54 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'Handybook_podTests.xctest' finished at 2014-06-13 16:34:54 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.000) seconds
Test Suite 'All tests' finished at 2014-06-13 16:34:54 +0000.
Executed 0 tests, with 0 failures (0 unexpected) in 0.000 (0.001) seconds
点击播放按钮时究竟执行了什么?似乎没有我写的东西正在运行。如何在ServicesSpec.m文件中运行代码?
文件如下:
// ServicesSpec.m
#import <XCTest/XCTest.h>
#import <Specta/Specta.h>
#define EXP_SHORTHAND
#import <Expecta/Expecta.h>
#import "Services.h"
SpecBegin(Services)
describe(@"Services", ^{
it(@"Should get the Most Common Services", ^AsyncBlock{
[Services getMostCommonServices:^(id responseObject) {
// a bunch of Expecta matchers/tests to check the responseObject
NSLog(@"Most Common Services Tests Passed!");
done();
} failureBlock:^(NSError *error) {
NSLog(@"%@", error.userInfo);
done();
}];
});
});
SpecEnd