【发布时间】:2017-10-13 17:48:12
【问题描述】:
我有一个 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
但它的行数仍然相同。
【问题讨论】:
-
--format progress似乎没有显示该输出,但它也没有显示失败的测试。--format progress2显示失败测试的回溯(但不显示输出),--format progress3也是如此。 -
是的,这就行了!
--format比我意识到的要强大得多。谢谢! -
好的,我不确定你想要什么。我已将其发布为答案。无论如何,如果有办法将步骤描述与失败测试的回溯一起提供,那就太好了,但是,AFAIK,没有内置的格式化程序可以做到这一点。
标签: python acceptance-testing python-behave