XCFit 4 released : Swift 3.1, Carthage and Pre-defined BDD Steps Support

XCFit is full stack iOS BDD framework in Xcode. XCFit setup Xcode templates with skeleton code and directory structures which helps us to get started with BDD and XCFit Swift Framework provides lots of predefined BDD Style steps to automated BDD with less code. You can read details of XCFit on Github. XCFit 4.0 is jus released with lots of features, the brief release notes are available on GitHub here.  Let”s see what’s new in the XCFit 4 in details  in this post.

XCFit 4.0

XCFit 4.0 is a major release with lot of improvements on Swift Frameworks. The XCFit 4 .0 has following major changes.

  • Support for Swift 3.1 and Xcode 8.3
  • Added Carthage Support for the XCFit Framework with Integrated Cucumberish library.
  • Added lots of Predefined steps for the XCFit and Cucumberish, so that we can use them directly into our project.
  • Xcode templates are improved by separating and XCFit and Fitnesse templates in different command.
  • Improved README and Web page documentation of XCFit with Video Demo on Youtube.
  • Let’s see new changes in brief.

Swift 3.1 Support

Apple has just release Swift-3.1-dev snapshot with some useful changes in the XCTest framework. You can read about newly added classes in the XCUITests on my DZone blog. Basically, XCUITest now support asynchronous testing and able to to control Siri with new classes. Apple has added XCWaiter class for better waiter waiting which has beed utilised by XCFit.

XCFit 4.0 is fully built on Swift 3.1, you can see the Swift version on Cocoapods. The idea is to fully support XCFit Swift framework from XCFt 3.1 onwards. You might need to wait until Swift 3.1 public release to use new features of XCFit 4.0 if you don’t have Swift 3.1 installed yet.

Carthage Support

XCFit Swift framework can now be built using Carthage, previously it was used with Cocoapods only but XCFit 4.0 added support to Carthage as well. XCFit has dependency on Cucumberish frameworks so that we can get both of these framework by pulling XCFit. Just add following to Cartfile  in your project root

Now, we can download and build the frameworks using following command

Now we can set both XCFit and Cucumberish target manually.

Setting XCFit Swift Framework

The above command will create ‘Carthage’ directory with built framework. We need to manually drag and drop this to our XCUIPoMTest’ target build settings. On your application targets’ “General” settings tab, in the “Linked Frameworks and Libraries” section, drag and drop each framework you want to use from the Carthage/Build folder on disk. On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: bin/sh), add the following contents to the script area below the shell:

and add the paths to the frameworks you want to use under “Input Files”, e.g.:

It should like this:

Setting Cucumberish Framework

We can setup Cucumberish as well. Now we need to manually drag and drop frameworks in the build phases  of the Cucumberish target.

  • From the build phases of the cucumberish target select Link Binary with Libraries  and drag Cucumberish.framework from Carthage/Build/iOS  directory. We need to add new ‘Copy Files’ phase and select destination as ‘Frameworks’ and Add Cucumberish Frameworks from directory. Select ‘Create Group’ and ‘Copy if needed’ when prompted. The entire Carthage Setup looks like this

 

Pre-Defined BDD Steps

XCFit4.0  has pre-defined steps for both XCFit Swift framework as well as Cucumberish framework.

It’s recommended to use your own steps as predefined steps might not read well for your project needs. Pre-defined steps gives you guidance on how to implement your own step, however you can use pre-defined steps wherever they make sense to avoid duplication. The pre-defined steps will be available directly into Xcode once you import XCFit  and extend the test class to XCFit framework.

There are some pre-defined Cucumberish Steps available to use directly without any need to implement in the step definition. You can see list of steps here. You already have those steps in the ‘CommonStepDefinitions.swift’ file. You can modify the steps as per your project need or add your own.

Extending BDD Step from XCFit Framework

XCFit has a step givenILaunchedApplication()  and you are not happy about the wordings. You can easily write and Extension and your steps like this :

Now you can use your own givenMyiOSApplicationHasBeenLaunched()  step anywhere inside the Test target.

Extending/Changing Cucumberish BDD Steps

XCFit template for setting Cucumberish has the Swift code for the all pre-defined Cucumberish BDD Steps inside the ‘CommonStepDefinitions.swift’ file. You just need to add your own steps accordingly or change the exiasting one.

Updated README and Video Demo

XCFit 4.0 has improved documentation on Github README and it’s web page . You can see step by step guide on using XCFit frameworks. There is also video demo o Youtube, you can watch here

[embedyt] http://www.youtube.com/watch?v=7gqPxy6UVRw[/embedyt]

Hope you like XCFit 4.0