How to set sauce-labs job result as pass or fail using karate?

♀尐吖头ヾ 提交于 2021-01-27 18:54:57

问题


I'm trying to run a simple test scenario on sauce-labs, but the issue is that sauce-labs doesn't identify the test-status as passed or failed on its own. I've gone through multiple solutions but couldn't make any of them work.

I would love to know if we can do something in the feature file rather than doing something externally if possible. Following are my feature and java files.

Feature File
1

Java File
2

Any help will be appreciated. I'm a JAVA newbie & just starting on the Karate Framework and do not have in-depth knowledge of how things are working.


回答1:


The Remote Driver is just sending along requests for actions and requests for information. What that information is "supposed" to be is decided by the assertions in your test. Sauce Labs has no way of knowing what that is without your input.

There are 2 ways to tell Sauce Labs the status of the test.

The recommended way is to use the API: https://wiki.saucelabs.com/display/DOCS/Job+Methods#JobMethods-UpdateJob You just need your sauce username, access key and the job ID (job ID is the same as the driver's session ID).

The less reliable, but easier to implement way is with a custom JavaScript command: https://wiki.saucelabs.com/display/DOCS/Annotating+Tests+with+Selenium%27s+JavaScript+Executor "sauce:job-result=passed"

Either of these can be put into an AfterClass or TestWatcher methods.



来源:https://stackoverflow.com/questions/63264238/how-to-set-sauce-labs-job-result-as-pass-or-fail-using-karate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!