File: step_dialect.given_when_then.feature

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (89 lines) | stat: -rw-r--r-- 2,441 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Feature: Step Dialect for BDD Steps with Given/When/Then Keywords

  In order to execute a sequence of steps with BDD keywords (Given/When/Then)
  As a test/story writer
  I want to have the possibility to express myself.
  
  . NOTE:
  .   * More details are provided in other features.


  Scenario: Simple example

    Normally preferred style with BDD keywords.
    Note that BDD keywords are dependent on language settings.

      Given a step passes
      When a step passes
      And a step passes
      Then a step passes
      And a step passes
      But a step passes


  Scenario: Simple example (with lower-case keywords)

    Alternative style with lower-case BDD keywords.

      given a step passes
      when a step passes
      and a step passes
      then a step passes
      and a step passes
      but a step passes


  Scenario: Step usage example with details by running behave
    Given a new working directory
    And a file named "features/steps/steps.py" with:
        """
        from behave import given, when, then, step

        @given('a step passes')
        def given_step_passes(context):
            pass

        @when('a step passes')
        def when_step_passes(context):
            pass

        @then('a step passes')
        def then_step_passes(context):
            pass

        @step('a step passes with "{param}"')
        def step_passes_with_param(context, param):
            pass

        @step('another step passes')
        def step_passes(context):
            pass

        @step('another step passes with "{param}"')
        def step_passes(context, param):
            pass
        """
    And a file named "features/basic_steps.feature" with:
        """
        Feature:
          Scenario:
            Given a step passes
            And another step passes
            When a step passes with "Alice"
            Then another step passes with "Bob"
        """
    When I run "behave -f plain -T features/basic_steps.feature"
    Then it should pass with:
        """
        1 scenario passed, 0 failed, 0 skipped
        4 steps passed, 0 failed, 0 skipped
        """
    And the command output should contain:
        """
        Feature:
          Scenario:
            Given a step passes ... passed
            And another step passes ... passed
            When a step passes with "Alice" ... passed
            Then another step passes with "Bob" ... passed
        """