【问题标题】:KIF 2.0 with Specta 0.2.1带有 Specta 0.2.1 的 KIF 2.0
【发布时间】:2014-01-03 15:01:40
【问题描述】:

是否可以将 KIF 2.0 与 Specta 0.2.1 一起使用?在 KIF GitHub 存储库 (https://github.com/kif-framework/KIF) 上,他们添加了一个带有 Specta 的示例,但我无法使其正常工作,可能是因为 Specta 正在使用 XCTest 而不是 SenTestKit。也许我可以使用较早版本的 Specta,有人可以使用吗?

感谢您的帮助。

【问题讨论】:

    标签: ios tdd automated-tests bdd kif


    【解决方案1】:

    我发现我必须在 Specta 的 SPTXCTestCase 中添加一个类别才能让 KIF 2.0 和 Specta 0.2.1 发挥出色(尽管自述文件在 KIF 2.0 中是这样说的)。我相信这确实是因为 KIF 不能开箱即用,XCTest 和 Specta 在版本 2 中从 OCTest 切换到 XCTest。

    SPTXCTestCase+KIF.h

    @protocol KIFTestActorDelegate;
    
    @interface SPTXCTestCase (KIF) <KIFTestActorDelegate>
    
    @end
    

    SPTXCTestCase+KIF.m

    #import "SPTXCTestCase+KIF.h"
    #import <SenTestingKit/SenTestingKit.h>
    
    @implementation SPTXCTestCase (KIF)
    
    - (void)failWithException:(NSException *)exception stopTest:(BOOL)stop {
        [self recordFailureWithDescription:exception.userInfo[SenTestDescriptionKey]
                                    inFile:exception.userInfo[SenTestFilenameKey]
                                    atLine:[exception.userInfo[SenTestLineNumberKey] intValue]
                                  expected:NO];
    }
    
    - (void)failWithExceptions:(NSArray *)exceptions stopTest:(BOOL)stop {
        for (NSException *exception in exceptions) {
            [self failWithException:exception stopTest:stop];
    }
    
    @end
    

    【讨论】:

    • Use of undeclared identifier 'SenTestDescriptionKey'
    • 它包含在 中,KIF 将其作为其 Pod 的一部分导入。我想如果您不使用 pod,您可能必须手动导入它。我将编辑我的答案以包含它。
    【解决方案2】:

    修正,好像那些键不存在

    - (void)failWithException:(NSException *)exception stopTest:(BOOL)stop
    {
      self.continueAfterFailure = !stop;
      [self recordFailureWithDescription:exception.description
                                  inFile:exception.userInfo[@"SenTestFilenameKey"]
                                  atLine:[exception.userInfo[@"SenTestLineNumberKey"] integerValue]
                                expected:NO];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-05
      • 2014-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多