测试完成后如何以编程方式获取Pytest测试结果

时间:2019-09-05 20:03:03

标签: python pytest zalenium

enter image description here 我正在使用Zalenium在docker中运行我的Pytest测试。 Zalenium仪表板需要与pytest进行某种通信才能获得结果。目前,Zalenium仪表板仅将结果报告为“已完成”,而不是“成功”或“失败”。我不确定如何从pytest获取PASS或FAIL结果,甚至不确定将Zalenium钩子放置在哪里的代码。 Zalenium的文档上有一个很好的例子,但它适用于Java和testNG。

By default, tests in Zalenium are marked in the dashboard either as COMPLETED (session finishes normally) or TIMEOUT (session was ended due to inactivity). You can mark the test as passed or failed based on the assertions you do on your side with your test framework, add a cookie from with the name zaleniumTestPassed with a value of true (if the test passes) or false (if the test fails). This could be done in the after method where you already know if the test passed or failed. Here is an example in Java:

Cookie cookie = new Cookie("zaleniumTestPassed", "true");
    webDriver.manage().addCookie(cookie);

0 个答案:

没有答案
相关问题