Created
June 15, 2011 17:45
-
-
Save tmpvar/1027636 to your computer and use it in GitHub Desktop.
xunit output from jasmine tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (phantom.state.length === 0) { | |
if (phantom.args.length !== 1) { | |
console.log('Usage: run-jasmine.js URL'); | |
phantom.exit(); | |
} else { | |
phantom.state = 'run-jasmine'; | |
phantom.open(phantom.args[0]); | |
} | |
} else { | |
window.setInterval(function () { | |
if ($('.finished-at').text().trim() !== '' && $('.spec').length > 0) { | |
/* | |
<?xml version="1.0" encoding="UTF-8"?> | |
<testsuite name="nosetests" tests="1" errors="1" failures="0" skip="0"> | |
<testcase classname="path_to_test_suite.TestSomething" | |
name="path_to_test_suite.TestSomething.test_it" time="0"> | |
<error type="exceptions.TypeError"> | |
Traceback (most recent call last): | |
... | |
TypeError: oops, wrong type | |
</error> | |
</testcase> | |
</testsuite> | |
*/ | |
var | |
total = $('.spec').length, | |
failed = $('.spec.failed').length, | |
xml = [ | |
'<?xml version="1.0" encoding="UTF-8"?>\n', | |
'<testsuite name="jasmine-tests" tests="', total, '" errors="0"',' failures="', failed, '" skip="0">\n', | |
]; | |
// handle the error cases | |
$('.spec.failed').each(function(k, v) { | |
var | |
el = $(v); | |
name = el.find('.description:first').text(), | |
stack = ($('.stackTrace', el).length>0) ? | |
$('.stackTrace', el).text() + '\n' : | |
'', | |
message = $('.messages .resultMessage', el).text(), | |
error = [ | |
'<testcase classname="', name, '" name="', name, '" time="0">\n', | |
' <error type="Assertion">\n ', | |
' ', message, '\n', stack, | |
' </error>\n', | |
'</testcase>' | |
]; | |
xml.push(error.join('')); | |
}) | |
xml.push('</testsuite>') | |
console.log(xml.join('')); | |
phantom.exit(); | |
} | |
}, 100); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment