Publish Ember test results to Jenkins
We are using Jenkins to run our Ember builds.
Recently I wanted to publish the results of running ember test
to Jenkins, luckily for us, most of the required functionality at the Ember side was available in ember-cli.
Ember CLI
CI=1 ember test ci --silent --r xunit | tee logs/xunit.xml
A little breakdown of what is in this command:
CI=1
: This sets the environment variable CI=1, this is then later picked up by the testem test suite to make certain decisions. This can be seen in the testem.js
pasted below. You can see this in the process.env.CI
.
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
'Chrome'
],
browser_args: {
Chrome: {
ci: [
// --no-sandbox is needed when running Chrome inside a container
process.env.CI ? '--no-sandbox' : null,
'--headless',
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
'--window-size=1440,900'
].filter(Boolean)
}
}
};
ember test ci
, this runs ember-cli test suite, but triggers the browser_arg ci, in the testem.js above, this is the part in the Chrome
key of the json.
--silent
tells ember-cli to not output any warnings or other unrelated information.
--r xunit
tells ember to output the test results in the xunit format.
| tee logs/xunit.xml
pipes the output of ember-cli, to the file xunit.xml in the logs directory.
Jenkins
For jenkins to understand the xml output of ember-cli, we must install a plugin. Go to manage jenkins > manage plugins
and look for JUnit Plugin, enable the plugin, and restart jenkins.
Create or edit a project in Jenkins, and in your project, after changing the execute shell
command to the ember test command above.
add a Post-build Action and choose for Publish JUnit test result report, and configure what is needed:
Make sure that the Test report XMLs
is set to logs/*xml
, this is the same path we told ember-cli above to output the results.
Now you should see the test results graph appearing in the project, and per build the Test Result with a breakdown of all the tests and the details.