Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在Xcode中运行Specta测试?_Ios_Xcode_Unit Testing_Testing_Tdd - Fatal编程技术网

Ios 如何在Xcode中运行Specta测试?

Ios 如何在Xcode中运行Specta测试?,ios,xcode,unit-testing,testing,tdd,Ios,Xcode,Unit Testing,Testing,Tdd,我正在尝试使用Specta和Expecta框架在Xcode中对代码进行单元测试。我在网上阅读了许多教程,并相应地设置了我的文件(见下文)。设置完毕后,SpecBegin(Services)左侧会出现一个空菱形,当鼠标悬停在上方时,它会变成一个播放按钮 单击播放按钮后,我始终会收到以下输出: Test Suite 'All tests' started at 2014-06-13 16:34:54 +0000 Test Suite 'Handybook_podTests.xctest' start

我正在尝试使用Specta和Expecta框架在Xcode中对代码进行单元测试。我在网上阅读了许多教程,并相应地设置了我的文件(见下文)。设置完毕后,SpecBegin(Services)左侧会出现一个空菱形,当鼠标悬停在上方时,它会变成一个播放按钮

单击播放按钮后,我始终会收到以下输出:

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
//ServicesSpec.m
#进口
#进口
#定义EXP\u速记
#进口
#导入“Services.h”
高级职员(服务)
描述(@“服务”^{
它(@“应该获得最常见的服务”^AsyncBlock{
[服务getMostCommonServices:^(id响应对象){
//检查响应对象的一组Expecta匹配器/测试
NSLog(@“最常见的服务测试通过!”);
完成();
}故障块:^(N错误*错误){
NSLog(@“%@”,error.userInfo);
完成();
}];
});
});
SpecEnd

尝试一个简单的非异步块测试。它改变了什么吗?你也在用椰子荚吗否则,您可能缺少依赖库或框架。最后,ServicesSpec是测试项目目标的一部分吗?@dB否,是,是。我意识到我使用的是Specta版本0.1.11。我仍然不知道为什么测试没有用那个版本运行。我更新了Specta版本0.2.1的pod文件,这是根据的最新版本,现在测试正在运行。算计