如何使用空手道将调味料实验室的工作结果设置为通过或失败? [英] How to set sauce-labs job result as pass or fail using karate?

查看:89
本文介绍了如何使用空手道将调味料实验室的工作结果设置为通过或失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在调味酱实验室中运行一个简单的测试方案,但是问题在于,调味酱实验室无法单独确定测试状态为通过还是失败.我经历了多种解决方案,但无法使它们中的任何一种起作用.

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.

我想知道我们是否可以在功能文件中执行某些操作,而不是在可能的情况下进行外部操作.以下是我的功能和Java文件.

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

Java文件

Java File

任何帮助将不胜感激.我是JAVA新手&只是从空手道框架开始,对事物的运作方式没有深入的了解.

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.

推荐答案

Remote Driver仅发送操作请求和信息请求.该信息被假定"为什么?由测试中的断言决定.没有您的输入,Sauce Labs无法知道那是什么.

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.

有两种方法可以告诉Sauce Labs测试状态.

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

推荐的方法是使用API​​: https://wiki.saucelabs.com/display/DOCS/Job+方法#JobMethods-UpdateJob 您只需要您的酱汁用户名,访问密钥和作业ID(作业ID与驾驶员的会话ID相同).

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).

可靠性较低,但更易于实现的方法是使用自定义JavaScript命令: https://wiki.saucelabs.com/display/DOCS/Annotating + Tests + with + Selenium%27s + JavaScript + Executor " sauce:job-result = passed"

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"

这些都可以放入AfterClass或TestWatcher方法中.

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

这篇关于如何使用空手道将调味料实验室的工作结果设置为通过或失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆