KIF 2.0 with Specta 0.2.1

339 Views Asked by At

Is it possible to use KIF 2.0 with Specta 0.2.1? On KIF GitHub repository (https://github.com/kif-framework/KIF) they add an example with Specta but I can't get this working, probably because Specta is using XCTest and not SenTestKit anymore. Maybe I can use a earlier version of Specta, anyone has got this working?

Thanks for the help.

2

There are 2 best solutions below

2
On

I found that I had to add a category to Specta's SPTXCTestCase in order to get KIF 2.0 and Specta 0.2.1 to play nice (despite what the README says in KIF 2.0). I believe this is indeed because KIF does not work out of the box with XCTest and Specta switched from OCTest to XCTest in version 2.

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
0
On

Amendment, seems those keys don't exist

- (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];
}