在行为的场景描述中可以使用长字符串吗?

时间:2019-03-27 14:50:43

标签: python cucumber bdd python-behave

我正在尝试通过行为测试获得一些美观的输出。

example.feature

# language: en

Feature: My feature

  Scenario: As admin I want to listen special music, wear some Acapulco shirt, erase db and do not want to bear any responsibility

    Given given step
    When when step
    Then then step

steps.py

from behave import *


@given('given step')
def given(context):
    pass


@when('when step')
def given(context):
    pass


@then('then step')
def given(context):
    pass

输出

Feature: My feature # features/example-scenario.feature:3

  Scenario: As admin I want to listen special music, wear some Acapulco shirt, erase db and do not want to bear any responsibility  # features/example-scenario.feature:5
    Given given step                                                                                                                # features/steps/x.py:4
    When when step                                                                                                                  # features/steps/x.py:9
    Then then step                                                                                                                  # features/steps/x.py:14

1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.002s

如您所见,输出按方案字符串对齐。它破坏了输出,因为如果我想在不太宽的窗口中使用它,并使日志不可读。 我尝试对YAML使用多行技巧,但是Behave似乎只能与单个字符串一起使用。请给我一个提示,如何使输出看起来像这样:

Feature: My feature # features/example-scenario.feature:3

  Scenario: As admin I want to listen special music,
  wear some Acapulco shirt, erase db
  and do not want to bear any responsibility  # features/example-scenario.feature:5
    Given given step                          # features/steps/x.py:4
    When when step                            # features/steps/x.py:9
    Then then step                            # features/steps/x.py:14

0 个答案:

没有答案