fixes #48 - XML Output file doesn't have classpath populated with file name
Showing
2 changed files
with
11 additions
and
2 deletions
... | @@ -91,12 +91,18 @@ XUnitExporter.prototype.addFailure = function(classname, name, message, type) { | ... | @@ -91,12 +91,18 @@ XUnitExporter.prototype.addFailure = function(classname, name, message, type) { |
91 | * @return String | 91 | * @return String |
92 | */ | 92 | */ |
93 | function generateClassName(classname) { | 93 | function generateClassName(classname) { |
94 | classname = classname.replace(phantom.casperPath, "").trim(); | ||
94 | var script = classname || phantom.casperScript; | 95 | var script = classname || phantom.casperScript; |
95 | if (script.indexOf(fs.workingDirectory) === 0) { | 96 | if (script.indexOf(fs.workingDirectory) === 0) { |
96 | script = script.substring(fs.workingDirectory.length + 1); | 97 | script = script.substring(fs.workingDirectory.length + 1); |
97 | return script.substring(0, script.lastIndexOf('.')); | ||
98 | } | 98 | } |
99 | return classname || "unknown"; | 99 | if (script.indexOf('/') === 0) { |
100 | script = script.substring(1, script.length); | ||
101 | } | ||
102 | if (~script.indexOf('.')) { | ||
103 | script = script.substring(0, script.lastIndexOf('.')); | ||
104 | } | ||
105 | return script || "unknown"; | ||
100 | } | 106 | } |
101 | 107 | ||
102 | /** | 108 | /** | ... | ... |
... | @@ -7,7 +7,10 @@ xunit.addFailure('bar', 'baz', 'wrong', 'chucknorriz'); | ... | @@ -7,7 +7,10 @@ xunit.addFailure('bar', 'baz', 'wrong', 'chucknorriz'); |
7 | casper.test.assertMatch(xunit.getXML(), /<testcase classname="bar" name="baz"><failure type="chucknorriz">wrong/, 'XUnitExporter.addFailure() adds a failed testcase'); | 7 | casper.test.assertMatch(xunit.getXML(), /<testcase classname="bar" name="baz"><failure type="chucknorriz">wrong/, 'XUnitExporter.addFailure() adds a failed testcase'); |
8 | 8 | ||
9 | // named classname | 9 | // named classname |
10 | xunit = require('xunit').create(); | ||
10 | xunit.addSuccess(require('fs').workingDirectory + '/plop.js', 'It worked'); | 11 | xunit.addSuccess(require('fs').workingDirectory + '/plop.js', 'It worked'); |
11 | casper.test.assertMatch(xunit.getXML(), /<testcase classname="plop" name="It worked"/, 'XUnitExporter.addSuccess() handles class name'); | 12 | casper.test.assertMatch(xunit.getXML(), /<testcase classname="plop" name="It worked"/, 'XUnitExporter.addSuccess() handles class name'); |
13 | xunit.addSuccess(require('fs').workingDirectory + '/plip.js', 'Failure'); | ||
14 | casper.test.assertMatch(xunit.getXML(), /<testcase classname="plip" name="Failure"/, 'XUnitExporter.addFailure() handles class name'); | ||
12 | 15 | ||
13 | casper.test.done(); | 16 | casper.test.done(); |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment