序言
更新改造pytestcmd实行测试用例时 ,回到的內容 。
加上用例叙述
在撰写测试用例时,若将测试目地写成测试用例名称,将会会造成 用例名称太长 ,可是应用简洁明了的序号表明用例名称时,从实行結果中又没法了解实际的测试逻辑性,根据此 ,要想更新改造测试結果的回到內容,带上上用例叙述信息。
在conftest.py中加上编码以下:
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()
report.description = str(item.function.__doc__)
if not report.description:
report.nodeid = report.nodeid.encode("utf-8").decode("unicode_escape")
else:
report.nodeid = "Description of this test is : " report.description
实际效果以下:
test_doc.py::TestDoc::test_01
Description of this test is : this is the first test PASSED [ 33%]
test_doc.py::TestDoc::test_02
Description of this test is : this is the second test PASSED [ 66%]
test_doc.py::TestDoc::test_03
Description of this test is : None PASSED [100%]
如果有更强的解决方案,热烈欢迎留言板留言
文章来源于网络 ,如有侵权请联系站长QQ61910465删除本文版权归趣快排www.sEoguruBlog.com 所有,如有转发请注明来出,竞价开户托管,seo优化请联系QQ✈61910465