Beginning Sept 20, 2013 SAFS was enhanced to support Cucumber integration using Cucumber-JVM

SAFS users can now use Cucumber to define behavior-driven tests using standard Cucumber Feature files. When executing those tests via Cucumber-JVM there are SAFS Cukes classes that can automatically invoke and initialize the SAFS framework and execute commands and actions as directed by the Scenario Steps, or as called explicitly by the tester's own Java Step Definition implementations.

Requirements:
In order to use SAFS with Cucumber-JVM your environment must meet the following requirements:

  1. Minimum Cucumber-JVM installed with:
    • cucumber-core
    • cucumber-java

  2. SAFS Installed
    • SAFS Win only one tested with Cucumber-JVM at this time.
    • SAFS JAR libraries (up)dated to Sep 20, 2013 or later.
    • SAFS test project configured to run any SAFS Engines used for testing.
      (SAFS for RFT , SAFS for TestComplete, SAFS for Android, SAFS for iOS, SAFS IBT, etc..)
Usage:
Cucumber Feature Files:
Develop tests using standard Cucumber/Gherkin Feature file syntax. Scenario steps that don't map to SAFS StepDefinitions will map to your Java Step Definition files. When necessary, your Step Definition implementation can invoke SAFS Step Definition implementations allowing you to execute SAFS commands or actions when needed.
SAFS Scenario Steps:
You can cause Cucumber to invoke SAFS commands or actions directly by using the appropriate SAFS Step syntax in your Scenario Steps (Given, When, Then, etc..)
SAFS Commands (Driver Commands):
To cause the execution of a SAFS Command--also known as a Driver Command--the following Scenario step syntax is supported:
  • For a command taking no parameters:

    Then do safs command <command>

    Example:

    Then do safs command ClearAppMapCache

  • For a command taking one or more parameters use a standard syntax that Cucumber will parse into a List of values passed to running step definition. Generally, that means one or more values separated by commas with the entire set of values enclosed in double-quotes:

    Then do safs command <command> using "param 1, param 2, param 3"

    Examples:

    Then do safs command SetApplicationMap using "MyAppMap.map"
    Then do safs command GetAppMapValue using " , , theItem, theVar"

    (Note how a command's unused optional params must still be provided as empty values.)

SAFS Actions (Component Functions):
To cause the execution of a SAFS Action--also known as a Component Function--the following Scenario step syntax is supported:
  • For an action on a component taking no parameters:

    Then do safs action <action> on <windowname>
    Or
    Then do safs action <action> on <childname> in <windowname>

    Examples:

    Then do safs action Click on LoginWindow
    Or
    Then do safs action Click on Submit in LoginWindow

  • For an action on a component taking one or more parameters use a standard syntax that Cucumber will parse into a List of values passed to running step definition. Generally, that means one or more values separated by commas with the entire set of values enclosed in double-quotes:

    Then do safs <action> on <windowname> using "param 1, param 2, param 3"
    Or
    Then do safs <action> on <childname> in <windowname> using "param 1, param 2, param 3"

    Examples:

    Then do safs action Click on LoginWindow using "TopLeft"
    Or
    Then do safs action VerifyProperty on Submit in LoginWindow using "Enabled, True, CaseInsensitive"

SAFS Expressions and Variables:
If the Scenario Step is going to contain a SAFS expression then it must be entered as a double-quoted value since the Cucumber parser will want to strip the outer quotes off any value it sees:

""The variable value is: "& ^varValue"

Example:

Then do safs command LogMessage using ""The stored property value is: "& ^varValue"

Cucumber-JVM Step Definition Files:
To implement the Cucumber-JVM Step Definitions to access the SAFS Framework and available SAFS Step Definition methods at runtime, please consult the following:
  1. SAFS Cukes StepDriver class -- provides access to the SAFS Framework.
  2. SAFS Cukes SAFSSteps class -- step definitions superclass to extend.
  3. SAFS Cukes StepDefinitions class -- runtime access to SAFS Commands and Actions.

Primarily, any and all Cucumber-JVM step definition class files that intend to use SAFS *MUST* insure SAFS is running and initialized by implementing an @Before Cucumber hook, like below:

    @Before(order=10)
    public void beforeAll(){
        safsstep.beforeAll();
    }
    

The easiest way to do this is to have affected step definition classes extend the SAFSSteps class. Though, this is not required.

The SAFSSteps class provides all subclasses with ready access to the initialized SAFS JSAFSDriver and SAFS StepDefinition methods for running SAFS DriverCommands and ComponentFunctions.

You can invoke a SAFS DriverCommand or ComponentFunction from within your own step definition implementations like below:

    public void yourImplementedMethod(){
        helper = safsstep.runDriverCommand("SetApplicationMap", Arrays.asList("MyAppMap.map"));
        helper = safsstep.runComponentFunction("Click", "Submit", "LoginWindow", Arrays.asList("TopLeft"));
    }
    

Of course, you would want to use static String constants or other lookups rather than hardcoded literal Strings wherever possible.