Reputation: 409
I was using Jasmine reporter 1.x before and I could generate nice Junit Xml reports. but then we moved to Jasmine reporter2.x because of some new cool features. But the probelm is that I am unable to generate correct Junit XML report for my test results. My XML output looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite name="focused specs" timestamp="2015-07-31T17:00:42" hostname="localhost" time="6.225" errors="0" tests="3" skipped="0" disabled="0" failures="0">
<testcase classname="focused specs" name="DDD" time="2.169" />
<testcase classname="focused specs" name="EEE" time="1.514" />
<testcase classname="focused specs" name="FFF" time="0.615" />
</testsuite>
<testsuite name="focused specs.SQLITE" timestamp="2015-07-31T17:00:46" hostname="localhost" time="0" errors="0" tests="0" skipped="0" disabled="0" failures="0">
</testsuite>
<testsuite name="focused specs.System admin page UI - delete user from MS SQL database through UI" timestamp="2015-07-31T17:00:46" hostname="localhost" time="1.924" errors="0" tests="3" skipped="0" disabled="0" failures="0">
<testcase classname="focused specs.System admin page UI - delete user from MS SQL database through UI" name="AAA" time="1.018" />
<testcase classname="focused specs.System admin page UI - delete user from MS SQL database through UI" name="BBB" time="0.171" />
<testcase classname="focused specs.System admin page UI - delete user from MS SQL database through UI" name="CCC" time="0.225" />
</testsuite>
</testsuites>
I do not understand why i see 'focused specs' inside class and test suite names. Also for my first test suite you can see that the testsuite name is missing (replaced by 'focused specs') and shown in the next tag 'SQLITE'. This is how i am using the reporter plugin inside my .conf file:
exports.config = {
//multiCapabilities: [{'browserName': 'firefox'},{'browserName': 'chrome'},{'browserName': 'internet explorer'}],
capabilities: {'browserName': 'chrome'},
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['./runner/runner-*.js'],
allScriptsTimeout: 10000,
getPageTimeout: 10000,
framework: 'jasmine2',
onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
var capsPromise = browser.getCapabilities();
capsPromise.then(function(caps){
var browserName = caps.caps_.browserName.toUpperCase();
var browserVersion = caps.caps_.version;
var prePendStr = browserName + "-" + browserVersion + "-";
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'XML-Results',
filePrefix: prePendStr
}));
});
},
};
Any ideas as to why I am suffering?
Thanks.
Upvotes: 1
Views: 1516
Reputation: 11
I also had the same problem as you.
After doing research, I found out that onPrepare()
can optionally return a promise that Protractor will wait for before starting test execution.
What may be happening here is that the tests started executing before the report files are done initializing.
You can refer to this answer
I was able to resolve this by returning a promise when getting browser capabilities:
onPrepare: function () {
var jasmineReporters = require('jasmine-reporters');
// return promise here to ensure this gets completed before tests run
return browser.getCapabilities().then(function (caps) {
var browserName = caps.caps_.browserName.toUpperCase();
var browserVersion = caps.caps_.version;
var prePendStr = browserName + "-" + browserVersion + "-";
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'XML-Results',
filePrefix: prePendStr
}));
});
}
Please let me know if this helps.
Upvotes: 1