Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

67: Use XCTContext runActivityNamed:block: to insert the step's title in the report #72

Merged
merged 8 commits into from
Jul 18, 2017
32 changes: 25 additions & 7 deletions Cucumberish/Core/Managers/CCIStepsManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#import "CCIStep.h"
#import "CCIStepDefinition.h"

typedef void (^XCTContextActivityBlock)(id _Nullable activity);

static CCIStepsManager * instance = nil;


Expand Down Expand Up @@ -181,7 +183,29 @@ - (void)executeStep:(CCIStep *)step inTestCase:(id)testCase
implementation.type = @"And";
}

implementation.body(implementation.matchedValues, implementation.additionalContent);
XCTContextActivityBlock activityBlock = ^(id activity) {
implementation.body(implementation.matchedValues, implementation.additionalContent);
};

id xctContextClass = NSClassFromString(@"XCTContext");
if (xctContextClass) {
SEL aSelector = NSSelectorFromString(@"runActivityNamed:block:");

if ([xctContextClass respondsToSelector:aSelector]) {
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[xctContextClass methodSignatureForSelector:aSelector]];
[inv setSelector:aSelector];
[inv setTarget:xctContextClass];

NSString *name = [NSString stringWithFormat:@"%@ %@", step.keyword, step.text];
[inv setArgument:&(name) atIndex:2];
[inv setArgument:&(activityBlock) atIndex:3];

[inv invoke];
}
} else {
activityBlock(nil);
}

//Clean up the step additional content to avoid keeping unwanted objects in memory
implementation.additionalContent = nil;
if(step.keyword.length > 0){
Expand Down Expand Up @@ -257,9 +281,3 @@ void SStep(id testCase, NSString * stepLine)
step(testCase, stepLine);
}







1 change: 0 additions & 1 deletion Cucumberish/Cucumberish.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#import "CCIStepsManager.h"
#import "CCIBlockDefinitions.h"


/**
Cucumberish is the main class you will need to parse your feature files and execute them.
You should not create instances of this class directly, instead you need to use the instance method.
Expand Down