github.com/lonnblad/godog@v0.7.14-0.20200306004719-1b0cb3259847/features/formatter/pretty.feature (about)

     1  Feature: pretty formatter
     2    In order to support tools that import pretty output
     3    I need to be able to support pretty formatted output
     4  
     5    Scenario: Support of Feature Plus Scenario Node
     6      Given a feature "features/simple.feature" file:
     7      """
     8          Feature: simple feature
     9              simple feature description
    10          Scenario: simple scenario
    11              simple scenario description
    12      """
    13      When I run feature suite with formatter "pretty"
    14      Then the rendered output will be as follows:
    15      """
    16        Feature: simple feature
    17          simple feature description
    18  
    19          Scenario: simple scenario # features/simple.feature:3
    20  
    21        1 scenarios (1 undefined)
    22        No steps
    23        0s
    24      """
    25  
    26    Scenario: Support of Feature Plus Scenario Node With Tags
    27      Given a feature "features/simple.feature" file:
    28      """
    29          @TAG1
    30          Feature: simple feature
    31              simple feature description
    32          @TAG2 @TAG3
    33          Scenario: simple scenario
    34              simple scenario description
    35      """
    36      When I run feature suite with formatter "pretty"
    37      Then the rendered output will be as follows:
    38      """
    39        Feature: simple feature
    40          simple feature description
    41  
    42          Scenario: simple scenario # features/simple.feature:5
    43  
    44        1 scenarios (1 undefined)
    45        No steps
    46        0s
    47      """
    48    Scenario: Support of Feature Plus Scenario Outline
    49      Given a feature "features/simple.feature" file:
    50      """
    51          Feature: simple feature
    52              simple feature description
    53  
    54          Scenario Outline: simple scenario
    55              simple scenario description
    56  
    57          Examples: simple examples
    58          | status |
    59          | pass   |
    60          | fail   |
    61      """
    62      When I run feature suite with formatter "pretty"
    63      Then the rendered output will be as follows:
    64      """
    65        Feature: simple feature
    66          simple feature description
    67  
    68          Scenario Outline: simple scenario # features/simple.feature:4
    69  
    70            Examples: simple examples
    71              | status |
    72              | pass   |
    73              | fail   |
    74  
    75        2 scenarios (2 undefined)
    76        No steps
    77        0s
    78      """
    79  
    80    Scenario: Support of Feature Plus Scenario Outline With Tags
    81      Given a feature "features/simple.feature" file:
    82      """
    83          @TAG1
    84          Feature: simple feature
    85              simple feature description
    86  
    87          @TAG2
    88          Scenario Outline: simple scenario
    89              simple scenario description
    90  
    91          @TAG3
    92          Examples: simple examples
    93          | status |
    94          | pass   |
    95          | fail   |
    96      """
    97      When I run feature suite with formatter "pretty"
    98      Then the rendered output will be as follows:
    99      """
   100        Feature: simple feature
   101          simple feature description
   102  
   103          Scenario Outline: simple scenario # features/simple.feature:6
   104  
   105            Examples: simple examples
   106              | status |
   107              | pass   |
   108              | fail   |
   109  
   110        2 scenarios (2 undefined)
   111        No steps
   112        0s
   113      """
   114    Scenario: Support of Feature Plus Scenario With Steps
   115      Given a feature "features/simple.feature" file:
   116      """
   117          Feature: simple feature
   118              simple feature description
   119  
   120          Scenario: simple scenario
   121              simple scenario description
   122  
   123          Given passing step
   124          Then a failing step
   125  
   126      """
   127      When I run feature suite with formatter "pretty"
   128      Then the rendered output will be as follows:
   129      """
   130        Feature: simple feature
   131          simple feature description
   132  
   133          Scenario: simple scenario # features/simple.feature:4
   134            Given passing step      # suite_context.go:0 -> SuiteContext.func2
   135            Then a failing step     # suite_context.go:0 -> *suiteContext
   136            intentional failure
   137  
   138        --- Failed steps:
   139  
   140          Scenario: simple scenario # features/simple.feature:4
   141            Then a failing step # features/simple.feature:8
   142              Error: intentional failure
   143  
   144  
   145        1 scenarios (1 failed)
   146        2 steps (1 passed, 1 failed)
   147        0s
   148      """
   149    Scenario: Support of Feature Plus Scenario Outline With Steps
   150      Given a feature "features/simple.feature" file:
   151      """
   152        Feature: simple feature
   153          simple feature description
   154  
   155          Scenario Outline: simple scenario
   156          simple scenario description
   157  
   158            Given <status> step
   159  
   160          Examples: simple examples
   161          | status |
   162          | passing |
   163          | failing |
   164  
   165      """
   166      When I run feature suite with formatter "pretty"
   167      Then the rendered output will be as follows:
   168      """
   169        Feature: simple feature
   170          simple feature description
   171  
   172          Scenario Outline: simple scenario # features/simple.feature:4
   173            Given <status> step             # suite_context.go:0 -> SuiteContext.func2
   174  
   175            Examples: simple examples
   176              | status  |
   177              | passing |
   178              | failing |
   179                intentional failure
   180  
   181        --- Failed steps:
   182  
   183          Scenario Outline: simple scenario # features/simple.feature:4
   184            Given failing step # features/simple.feature:7
   185              Error: intentional failure
   186  
   187  
   188        2 scenarios (1 passed, 1 failed)
   189        2 steps (1 passed, 1 failed)
   190        0s
   191      """
   192  
   193    # Currently godog only supports comments on Feature and not
   194    # scenario and steps.
   195    Scenario: Support of Comments
   196      Given a feature "features/simple.feature" file:
   197      """
   198          #Feature comment
   199          Feature: simple feature
   200            simple description
   201  
   202            Scenario: simple scenario
   203            simple feature description
   204      """
   205      When I run feature suite with formatter "pretty"
   206      Then the rendered output will be as follows:
   207      """
   208        Feature: simple feature
   209          simple description
   210  
   211          Scenario: simple scenario # features/simple.feature:5
   212  
   213        1 scenarios (1 undefined)
   214        No steps
   215        0s
   216      """
   217    Scenario: Support of Docstrings
   218      Given a feature "features/simple.feature" file:
   219      """
   220          Feature: simple feature
   221            simple description
   222  
   223            Scenario: simple scenario
   224            simple feature description
   225  
   226            Given passing step
   227            \"\"\" content type
   228            step doc string
   229            \"\"\"
   230      """
   231      When I run feature suite with formatter "pretty"
   232      Then the rendered output will be as follows:
   233      """
   234        Feature: simple feature
   235          simple description
   236  
   237          Scenario: simple scenario # features/simple.feature:4
   238            Given passing step      # suite_context.go:0 -> SuiteContext.func2
   239              \"\"\"  content type
   240              step doc string
   241              \"\"\"
   242  
   243        1 scenarios (1 passed)
   244        1 steps (1 passed)
   245        0s
   246      """
   247    Scenario: Support of Undefined, Pending and Skipped status
   248      Given a feature "features/simple.feature" file:
   249      """
   250        Feature: simple feature
   251        simple feature description
   252  
   253        Scenario: simple scenario
   254        simple scenario description
   255  
   256          Given passing step
   257          And pending step
   258          And undefined
   259          And passing step
   260  
   261      """
   262      When I run feature suite with formatter "pretty"
   263      Then the rendered output will be as follows:
   264      """
   265        Feature: simple feature
   266          simple feature description
   267  
   268          Scenario: simple scenario # features/simple.feature:4
   269            Given passing step      # suite_context.go:0 -> SuiteContext.func2
   270            And pending step        # suite_context.go:0 -> SuiteContext.func1
   271              TODO: write pending definition
   272            And undefined
   273            And passing step        # suite_context.go:0 -> SuiteContext.func2
   274  
   275        1 scenarios (1 pending, 1 undefined)
   276        4 steps (1 passed, 1 pending, 1 undefined, 1 skipped)
   277        0s
   278  
   279        You can implement step definitions for undefined steps with these snippets:
   280  
   281        func undefined() error {
   282          return godog.ErrPending
   283        }
   284  
   285        func FeatureContext(s *godog.Suite) {
   286          s.Step(`^undefined$`, undefined)
   287        }
   288      """