Skip to content

Install manually for Objective C

Ahmed Ali edited this page Nov 27, 2016 · 1 revision
  1. Add the Cucumberish folder to your test target. When prompted choose "Create groups".

  2. Go to your test target build settings, and add the following preprocessor macro:

    SRC_ROOT=@\"$(SRCROOT)\"
    
  3. Go to your test target folder and create a subfolder. Let's call it Features.

  4. Add this folder to your test target in Xcode and choose Create folder references. Features Folder as Folder not a Group Inside this folder, you will create the .feature files which will contain your test features and scenarios.

  5. In your test target project navigator, replace the content of the auto-created test case file with the following:

            #import "Cucumberish.h"
            __attribute__((constructor))
            void CucumberishInit()
            {
                //Define your step implememntations (the example project contains set of basic implementations using KIF)
                Given(@"it is home screen", ^void(NSArray *args, id userInfo) {
                    //Step implementation code goes here
                });
                And(@"all data cleared", ^void(NSArray *args, id userInfo) {
                    //Step implementation code goes here
                });
                //Optional step, see the comment on this property for more information
                [Cucumberish instance].fixMissingLastScenario = YES;
                //Tell Cucumberish the name of your features folder, and which bundle contains this directory. And Cucumberish will handle the rest...
                //The ClassThatLocatedInTheRootTestTargetFolder could be any class that exist side by side with your Features folder.
                //So if ClassThatLocatedInTheRootTestTargetFolder exist in the directory YourProject/YourTestTarget
                //Then in our example your .feature files are expected to be in the directory YourProject/YourTestTarget/Features
                NSBundle * bundle = [NSBundle bundleForClass:[ClassThatLocatedInTheRootTestTargetFolder class]];
    	
                [Cucumberish executeFeaturesInDirectory:@"Features" fromBundle:bundle includeTags:nil excludeTags:nil];
            }
  6. Only in case the name of folder that contains your test target files is different than the test target name, set the value of the Cucumberish property testTargetFolderName to the correct folder name before calling the execute method.

That's it!

Clone this wiki locally