python-behave:如何在命令行上显示所有print()语句?

时间:2017-01-24 14:49:45

标签: python-2.7 bdd python-behave

我的部分测试是在命令行中打印一些语句。

我按照这里提到的步骤: How can I see print() statements in behave (BDD)

但是,我无法从代码的最后一行看到print()语句。

我在命令行上运行了test_bdd.feature --no-capture,结果是:

Feature: Learning BDD # test_bdd.feature:1

  Scenario: Cooking test       # test_bdd.feature:3
    Given I am hungry          # steps/test_bdd.py:3 0.000s
    When my mother is shopping # steps/test_bdd.py:7 0.000s
    Then I cook a meal         # steps/test_bdd.py:11
print debug #1
print debug #2
    Then I cook a meal         # steps/test_bdd.py:11 0.000s

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.001s

^没有print debug #3出现在结果中。 有没有办法在命令行上显示此部分?

我的test_bdd.feature:

Feature: Learning BDD

  Scenario: Cooking test
    Given I am hungry
    When my mother is shopping
    Then I cook a meal

我的test_bdd.py:

from behave import *
from selenium import webdriver
@given("I am hungry")
def step_impl(context):
    pass

@when("my mother is shopping")
def step_impl(context):
    pass

@then("I cook a meal")
def step_impl(context):
    print ("print debug #1")
    print ("print debug #2")
    print ("print debug #3")  # this line is not printed

我使用了python-behave version:behave 1.2.5

0 个答案:

没有答案