Generating an XML file from a template based on the run specs...
This commit is contained in:
parent
a6fd38da1b
commit
28189d7f05
@ -32,7 +32,8 @@ module.exports = function(grunt) {
|
|||||||
|
|
||||||
var runners = {
|
var runners = {
|
||||||
default : __dirname + '/jasmine/templates/DefaultRunner.tmpl',
|
default : __dirname + '/jasmine/templates/DefaultRunner.tmpl',
|
||||||
requirejs : __dirname + '/jasmine/templates/RequireJSRunner.tmpl'
|
requirejs : __dirname + '/jasmine/templates/RequireJSRunner.tmpl',
|
||||||
|
junit : __dirname + '/jasmine/templates/JUnit.tmpl'
|
||||||
};
|
};
|
||||||
|
|
||||||
var runnerOptions = {
|
var runnerOptions = {
|
||||||
@ -53,7 +54,8 @@ module.exports = function(grunt) {
|
|||||||
host : '',
|
host : '',
|
||||||
template: 'default',
|
template: 'default',
|
||||||
templateOptions : {},
|
templateOptions : {},
|
||||||
phantomjs : {}
|
phantomjs : {},
|
||||||
|
junit: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.util._.defaults(options.templateOptions, runnerOptions[options.template] || {});
|
grunt.util._.defaults(options.templateOptions, runnerOptions[options.template] || {});
|
||||||
@ -204,6 +206,21 @@ module.exports = function(grunt) {
|
|||||||
status.skipped += skippedAssertions;
|
status.skipped += skippedAssertions;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
phantomjs.on('jasmine.reportJUnitResults',function(junitData){
|
||||||
|
if (options.junit && options.junit.path) {
|
||||||
|
grunt.file.copy(runners.junit, path.join(options.junit.path,'out-TEST.xml'), {
|
||||||
|
process : function(src) {
|
||||||
|
return grunt.util._.template(
|
||||||
|
src,
|
||||||
|
{
|
||||||
|
testsuites: junitData
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
phantomjs.on('jasmine.done',function(elapsed){
|
phantomjs.on('jasmine.done',function(elapsed){
|
||||||
phantomjs.halt();
|
phantomjs.halt();
|
||||||
status.duration = elapsed;
|
status.duration = elapsed;
|
||||||
@ -220,6 +237,3 @@ module.exports = function(grunt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
14
tasks/jasmine/templates/JUnit.tmpl
Normal file
14
tasks/jasmine/templates/JUnit.tmpl
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<testsuites>
|
||||||
|
<% testsuites.forEach(function(testsuite) { %>
|
||||||
|
<testsuite name="<%- testsuite.name %>" errors="<%= testsuite.errors %>" tests="<%= testsuite.tests %>" failures="<%= testsuite.failures %>" time="<%= testsuite.time %>" timestamp="<%= testsuite.timestamp %>">
|
||||||
|
<% testsuite.testcases.forEach(function(testcase) { %>
|
||||||
|
<testcase classname="<%- testcase.classname %>" name="<%- testcase.name %>" time="<%= testcase.time %>">
|
||||||
|
<% if (testcase.failureMessage) { %>
|
||||||
|
<failure><%= testsuite.failureMessage %></failure>
|
||||||
|
<% } %>
|
||||||
|
</testcase>
|
||||||
|
<% }) %>
|
||||||
|
</testsuite>
|
||||||
|
<% }) %>
|
||||||
|
</testsuites>
|
Loading…
Reference in New Issue
Block a user