如何只显示失败的测试行为?

时间:2017-10-13 17:48:12

标签: python acceptance-testing python-behave

我有一个Python 3.4项目,其中包含在behave框架(版本1.2.5)中构建的测试。当我运行测试时,我得到几百行输出,其中大部分描述了没有问题的步骤。当场景失败时,我需要滚动浏览所有这些输出以查找失败(这很容易被注意到,因为它是红色的,而传递的步骤是绿色的,但我仍然需要查找它)。

有没有办法让behave仅显示失败方案的输出?理想情况下,我将获得所有失败方案的输出以及在传递/失败/跳过多少个功能/方案/步骤结束时的摘要。如果它打印出所有内容但将所有失败放在最底层,我也会满意。

我运行behave --help并查看了this website,但未发现任何相关内容。然而,我肯定不是第一个对此感到恼火的人,我想有办法做到这一点。谢谢你的帮助!

编辑:--quiet标志简化了输出,但不删除它。例如,此输出:

Scenario Outline: Blank key identification -- @1.3 blank checks # tests/features/tkg.feature:15 Given we have pages with the wrong checksum # tests/features/steps/tkg_tests.py:30 0.000s When we check if the key is blank # tests/features/steps/tkg_tests.py:50 0.000s Then it is not blank # tests/features/steps/tkg_tests.py:55 0.000s

使用--quiet标志运行时

变为:

Scenario Outline: Blank key identification -- @1.3 blank checks Given we have pages with the wrong checksum # 0.000s When we check if the key is blank # 0.000s Then it is not blank # 0.000s

但它的线数仍然相同。

1 个答案:

答案 0 :(得分:2)

您可以在progressprogress2格式化程序中使用--format选项。

这不会显示未失败测试的输出(尽管它仍会显示文件名)。 progress2选项显示失败测试的回溯。