Skip to content

Install with Carthage for Swift

Brentley Jones edited this page Aug 23, 2017 · 4 revisions
  1. In your Cartfile add Cucumberish

    github "Ahmed-Ali/Cucumberish"
    
  2. Run 'carthage update' and add Cucumberish.framework to your test target

  3. Go to your test target build phases, and add a new Copy Files phase and set it like the screenshot Cucumberish framework in Copy Files phase

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

    SRC_ROOT=@\"$(SRCROOT)\"
    
  5. Make sure Defines Module Build Setting is set to Yes for your test target: Define modules build setting set to Yes

  6. Go to your test target folder and create a subfolder. Let's call it Features.

  7. 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.

  8. Replace the content of the auto-created test case file with the following:

            import Foundation
            import Cucumberish
            class CucumberishInitializer: NSObject {
                class func CucumberishSwiftInit()
                {
                     
                    //Create a bundle for the folder that contains your "Features" folder. In this example, the CucumberishInitializer.swift file is in the same directory as the "Features" folder.
                    let bundle = Bundle(for: CucumberishInitializer.self)
    
                    //All step definitions should be done before calling the following method
                    Cucumberish.executeFeatures(inDirectory: "Features", from: bundle, includeTags: nil, excludeTags: nil)
                }
            }
  9. Create a new Objective-C .m file

  10. Replace the contents of this file with the following:

            //Replace CucumberishExampleUITests with the name of your swift test target
            #import "CucumberishExampleUITests-Swift.h"
            __attribute__((constructor))
            void CucumberishInit()
            {
                [Cucumberish instance].testTargetSrcRoot = SRC_ROOT;
                [CucumberishInitializer CucumberishSwiftInit];
            }
  11. 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.

And you are ready to get started!

Clone this wiki locally