我们最近开始使用Behave(github链接)用于新的python Web服务的BDD.
有什么方法可以在测试失败时获得有关失败原因的详细信息吗?他们扔了AssertionError
,但他们从来没有表明究竟出了什么问题.例如,期望值和进入断言的实际值.
我们一直试图找到这样的现有功能,但我想它不存在.当然,这个问题的一个很好的答案是关于如何通过修改源代码来实现这种行为的提示和技巧,以及这个特性是否存在于其他类似的BDD框架中,如jBehave,NBehave或Cucumber?
今天,当测试失败时,输出结果如下:
Scenario: Logout when not logged in # features\logout.feature:6
Given I am not logged in # features\steps\logout.py:5
When I log out # features\steps\logout.py:12
Then the response status should be 401 # features\steps\login.py:18
Traceback (most recent call last):
File "C:\pro\venv\lib\site-packages\behave\model.py", line 1037, in run
match.run(runner.context)
File "C:\pro\venv\lib\site-packages\behave\model.py", line 1430, in run
self.func(context, *args, **kwargs)
File "features\steps\login.py", line 20, in step_impl
assert context.response.status == int(status)
AssertionError
Captured stdout:
api.new_session
api.delete_session
Captured logging: …
Run Code Online (Sandbox Code Playgroud)