简体   繁体   English

将状态从Travis发送到Sauce Labs

[英]Send build status from Travis to Sauce Labs

I have my testing up and running with Travis/SauceLabs. 我已经通过Travis / SauceLabs进行了测试并运行。 Now I would like to add a SauceLabs test badge to my repo. 现在,我想在我的仓库中添加一个SauceLabs测试徽章。

I added the badge markdown to my Readme file but how can I send the build pass/fail to SauceLabs? 我将徽章降价标记添加到了我的自述文件中,但是如何将构建通过/失败发送给SauceLabs? I found this instructions for Selenium, 我找到了有关硒的说明

Key: passed 关键:通过
Value type: bool 值类型:布尔
Example : "passed": true 示例 :“通过”:是

but how/where do I add info in my files for my Grunt-Karma/Travis/SauceLabs testing? 但是如何在文件中为Grunt-Karma / Travis / SauceLabs测试添加信息?

The Karma-Sauce-Launcher was using the wrong id , and this was fixed on Github by this PR and released in NPM as version 0.2.5 Karma-Sauce-Launcher使用了错误的id此PR已在Github上对其进行了修复,并在NPM中以0.2.50.2.5

Aditionally the saucelabs reporter has to be added to the gruntfile options, besides the existing ones or the default progress . 除了现有的或默认progress外,还必须将saucelabs报告程序添加到gruntfile选项中。

So the bugfix I added to my package.json: 所以我添加到package.json的错误修正:

"karma-sauce-launcher": "~0.2.5"

and added this: 并添加以下内容:

reporters: ['progress', 'saucelabs'],

in the Karma options. 在因果选项中。

You have to use the REST API . 您必须使用REST API What you would do is add code in a function that is executed at the very end of your test suite and knows the result of your test run. 您要做的是在测试套件的最后执行的函数中添加代码,并且知道测试运行的结果。 This code would have to perform a query equivalent to this curl command: 这段代码必须执行与以下curl命令等效的查询:

$ curl -H "Content-Type:text/json" -s -X PUT -d '{"passed": <status>}' http://<username>:<key>@saucelabs.com/rest/v1/<username>/jobs/<job-id>

(The identifiers in angular brackets have to be replaced with appropriate values.) (尖括号中的标识符必须替换为适当的值。)

I've done it with Python but I don't have JavaScript code to share. 我已经用Python完成了,但是我没有共享的JavaScript代码。 And by the way, you have to do this for Selenium too because as the documentation states, when Selenium sends the job data to Sauce Labs, it cannot know yet what the test result is going to be. 顺便说一句,您也必须对Selenium进行此操作,因为如文档所述,当Selenium将作业数据发送给Sauce Labs时,它尚不知道测试结果将是什么。

如果您已经在使用Grunt,则应该使用https://github.com/axemclion/grunt-saucelabs,因为它是SauceLabs开发人员开发的官方插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM