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 = {
|
||||
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 = {
|
||||
@ -53,7 +54,8 @@ module.exports = function(grunt) {
|
||||
host : '',
|
||||
template: 'default',
|
||||
templateOptions : {},
|
||||
phantomjs : {}
|
||||
phantomjs : {},
|
||||
junit: {}
|
||||
});
|
||||
|
||||
grunt.util._.defaults(options.templateOptions, runnerOptions[options.template] || {});
|
||||
@ -204,6 +206,21 @@ module.exports = function(grunt) {
|
||||
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.halt();
|
||||
status.duration = elapsed;
|
||||
@ -219,7 +236,4 @@ 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