Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixes #48 - XML Output file doesn't have classpath populated with fil…

…e name
  • Loading branch information...
commit e8e17db0519e379da8b280c9c0a0a5da6a1611a5 1 parent 062eba7
@n1k0 authored
Showing with 11 additions and 2 deletions.
  1. +8 −2 modules/xunit.js
  2. +3 −0  tests/suites/xunit.js
View
10 modules/xunit.js
@@ -91,12 +91,18 @@ XUnitExporter.prototype.addFailure = function(classname, name, message, type) {
* @return String
*/
function generateClassName(classname) {
+ classname = classname.replace(phantom.casperPath, "").trim();
var script = classname || phantom.casperScript;
if (script.indexOf(fs.workingDirectory) === 0) {
script = script.substring(fs.workingDirectory.length + 1);
- return script.substring(0, script.lastIndexOf('.'));
}
- return classname || "unknown";
+ if (script.indexOf('/') === 0) {
+ script = script.substring(1, script.length);
+ }
+ if (~script.indexOf('.')) {
+ script = script.substring(0, script.lastIndexOf('.'));
+ }
+ return script || "unknown";
}
/**
View
3  tests/suites/xunit.js
@@ -7,7 +7,10 @@ xunit.addFailure('bar', 'baz', 'wrong', 'chucknorriz');
casper.test.assertMatch(xunit.getXML(), /<testcase classname="bar" name="baz"><failure type="chucknorriz">wrong/, 'XUnitExporter.addFailure() adds a failed testcase');
// named classname
+xunit = require('xunit').create();
xunit.addSuccess(require('fs').workingDirectory + '/plop.js', 'It worked');
casper.test.assertMatch(xunit.getXML(), /<testcase classname="plop" name="It worked"/, 'XUnitExporter.addSuccess() handles class name');
+xunit.addSuccess(require('fs').workingDirectory + '/plip.js', 'Failure');
+casper.test.assertMatch(xunit.getXML(), /<testcase classname="plip" name="Failure"/, 'XUnitExporter.addFailure() handles class name');
casper.test.done();
Please sign in to comment.
Something went wrong with that request. Please try again.