简体   繁体   中英

Send build status from Travis to Sauce Labs

I have my testing up and running with Travis/SauceLabs. Now I would like to add a SauceLabs test badge to my repo.

I added the badge markdown to my Readme file but how can I send the build pass/fail to 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?

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

Aditionally the saucelabs reporter has to be added to the gruntfile options, besides the existing ones or the default progress .

So the bugfix I added to my 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 . 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 -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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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