Drupal Testing: PHP: 11 - PHP Behat BDD Project StandUp

 

Folders

  • \features
    • \bootstrap
      • FeatureContext.php
    • basket.feature
  • tests
    • pom
    • bdd
    • unit
    • 2e2
  • \vendor
    • behat
    • phpunit
      • phpunit
        • phunit
  •  

 

 

basket.feature

  •  
#Author: your.email@your.domain.com
#Keywords Summary :
#Feature: List of scenarios.
#Scenario: Business rule through list of steps with arguments.
#Given: Some precondition step
#When: Some key actions
#Then: To observe outcomes or validation
#And,But: To enumerate more Given,When,Then steps
#Scenario Outline: List of steps for data-driven as an Examples and <placeholder>
#Examples: Container for s table
#Background: List of steps run before each of the scenarios
#""" (Doc Strings)
#| (Data Tables)
#@ (Tags/Labels):To group Scenarios
#<> (placeholder)
#""
## (Comments)
#Sample Feature Definition Template
@tag
Feature: basket
  In order to purchase products
  As a customer
  I must add proudcts to my basket
 
  Scenario: I add a product to my basket
      When I add 1 product to my basket
      Then I have 1 product in my basket
      
      Scenario: I add 2 products to my basket
          When I add 1 product to my basket
          And I add 1 more product to my basket
          Then I have 2 products in my basket

 

 

Behat --init

  •  
c:\xampp\htdocs 
λ vendor\bin\behat --init

 

 

behat runner

  •  
c:\xampp\htdocs
λ vendor\bin\behat
@tag
Feature: basket
  In order to purchase products
  As a customer
  I must add proudcts to my basket

  Scenario: I add a product to my basket # features\basket.feature:25
    When I add 1 product to my basket
    Then I have 1 product in my basket

  Scenario: I add 2 products to my basket # features\basket.feature:29
    When I add 1 product to my basket
    And I add 1 more product to my basket
    Then I have 2 products in my basket

2 scenarios (2 undefined)
5 steps (5 undefined)
0m0.12s (6.79Mb)

 >> default suite has undefined steps. Please choose the context to generate snippets:

  [0] None
  [1] FeatureContext
 > 1
1

--- FeatureContext has missing steps. Define them with these snippets:

    /**
     * @When I add :arg1 product to my basket
     */
    public function iAddProductToMyBasket($arg1)
    {
        throw new PendingException();
    }

    /**
     * @Then I have :arg1 product in my basket
     */
    public function iHaveProductInMyBasket($arg1)
    {
        throw new PendingException();
    }

    /**
     * @When I add :arg1 more product to my basket
     */
    public function iAddMoreProductToMyBasket($arg1)
    {
        throw new PendingException();
    }

    /**
     * @Then I have :arg1 products in my basket
     */
    public function iHaveProductsInMyBasket($arg1)
    {
        throw new PendingException();
    }