I found a solution, just change the message ... :
casper.test.on("fail", function(failure) {
failure.message = "Message : " + failure.message + "\nLine : "+ failure.line + "\nCode : " + failure.lineContents;
});
The error resume stack (with test.begin) is also modified though. But I don't care in jenkins, so we can use a condition like if casper.cli.get('xunit') { casper.test.on('fail'){...} ;}
.
And so :
Rather simple actually ... I should have better search.
For Artjom :
In fact for errors it's quite verbose so I don't think there are changes to do, see :
But you can still customize it the same way and it could be something like that :
casper.test.on("fail", function(failure) {
//if error type undefined function
if(failure.message.message){//or failure.message.stack.TypeError
failure.message.message = "Message : " + failure.message.message + "\nLine : "+ failure.message.line;//in jenkins -> title
}
//else assert error
else{failure.message = "Message : " + failure.message + "\nLine : "+ failure.line + "\nCode : " + failure.lineContents;}
//console.log(JSON.stringify(failure,4,'\t')); //see parameters you can modify in the failure object
});
There isn't an error event, but different objects-properties- (compared to the type of error) in this fail event. So you can manipulate them in the way you want. But personally I'm interested by the message, the code and the line (and by default jenkins manages them with undefined error).
Now I'm working on a way to display also the screenshot path, to have something like that :
Message : No notice on the page
Line : 83
Code : this.test.assertTextDoesntExists('Notice', 'No notice on the page');
Screenshot : http://-jenkins-/job/-myJob-//lastFailedBuild/artifact/screenshots/fail0.png/
Well, I did it: https://github.com/n1k0/casperjs/pull/920
The aim is to click on the link in jenkins and display screen directly using the browser :)