How can I see print() statements in behave (BDD)

前端 未结 5 995
野趣味
野趣味 2020-12-08 06:38

Context: I am using Python with Behave (BDD).

Whether I run my tests from the command line (behave) or from a custom main(), the behavior is the same: the test runs

5条回答
  •  长情又很酷
    2020-12-08 07:11

    I figured it out after spending more time reading the documentation. It is actually quite simple. By default, behave does not display any output (i.e. by using print()) unless there is a failure in the test. To force displaying all output regardless of the outcome of the test (pass/fail), all you need is to change some of the default settings. The easiest way to achieve that is to create a file named behave.ini in the root of your project's directory and put the following:

    Filename: behave.ini

    [behave]
    stderr_capture=False
    stdout_capture=False
    

    Next time you run your behave tests, you will see all outputs from your debug statements whether your tests pass or fail.

提交回复
热议问题