Code Monkey home page Code Monkey logo

codeception-gherkin-param's Introduction

Gherkin Param

Packagist Latest Version Build Status Scrutinizer Code Quality Coverage Status GitHub license FOSSA Status

The Codeception extension for supporting parameter notation in Gherkin scenario.

Minimum Requirements

  • Codeception ≥ 2.2
  • PHP ≥ 7.0

Installation

The extension can be installed using Composer

$ composer require edno/codeception-gherkin-param

Be sure to enable the extension in codeception.yml as shown in configuration below.

Configuration

Enabling Gherkin Param is done in codeception.yml.

extensions:
    enabled:
        - Codeception\Extension\GherkinParam

Usage

Once installed you will be able to access variables stored using Fixtures.

Simple parameters

In scenario steps, the variables can be accessed using the syntax {{param}}.
While executing your features the variables will be automatically replaced by their value.

Array parameters

From version 0.3, you can refer to an element in an array using the syntax {{param[key]}}.
If the key does not exist, then null is returned.

Test Suite Config parameters

From version 0.3, you can refer to a test suite configuration parameter using the syntax {{config:param}}.
Note that the keyword config: is mandatory. If the config parameter does not exists, then null is returned.

Example

Feature: Parametrize Gherkin Feature
  In order to create dynamic Gherkin scenario
  As a tester
  I need to be able to share data between scenario steps

  Scenario: Scenario using simple parameter
    Given I have a parameter "test" with value "42"
    Then I should see "{{test}}" equals "42"

  Scenario: Scenario using array parameter
    Given I have an array "test" with values [1, two, 3.14, IV, 101]
    Then I should see "{{test[1]}}" equals "two"

  Scenario: Scenario using config parameter
    Given I have a configuration file "acceptance.suite.yml" containing
      """
      theResponse: 42
      """
    When I execute a scenario calling the parameter 'theResponse'
    Then I should see "{{config:theResponse}}" equals "42"

The steps definition in AcceptanceTester.php do not require any change

/**
 * @Given I have a parameter :param with value :value
 */
 public function iHaveAParameterWithValue($param, $value)
 {
   Fixtures::add($param, $value);
 }

/**
 * @Then I should see :arg1 equals :arg2
 */
 public function iSeeEqual($arg1, $arg2)
 {
   $this->assertEquals($arg1, $arg2);
 }

You can find more examples in the test folder.

License

FOSSA Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.