Closed scastrec closed 4 years ago
Hi,
It's been awhile I haven't touched these parts of the code due to lack of bandwidth. I'm not quite sure what I wrote anymore 😂 .
Thanks for pointing this out, I use mostly the java code so I must have missed this:
if (typeof this.details === "undefined") {
builder['statusDetails'] = this.details;
}
The one that's in charge of writing the file is the Reporter:
generateReportFiles() {
this.updateContainers(this.reportPath);
for(let i = 0; i < this.tests.length; i++) {
let fileName = this.reportPath + '/' + this.tests[i].getUuid() + "-result.json";
TestUtils.writeToFile(fileName, this.tests[i].text);
}
for(let i = 0; i < this.attachments.length; i++) {
this.attachments[i].saveToFile(this.reportPath);
}
}
Have you tried create the StatusDetail object and set the message to it, before setting the status detail to the step?
Or use an object that structured like how the status detail should be like:
{
"known": false,
"muted": false,
"flaky": false,
"message": "The test has contracted CoVid19!"
}
Sorry for the close/open.
It doesn't work properly either with the hardcoded object structure.
My log said that i Set correctly the details
Adding this.details {"known":false,"muted":false,"flaky":false,"message":"Failed to getStats"}
The temp/.../result.json is correct
{
"name": "[chrome] Get the peer connection's stats",
"start": 1588836879177,
"stop": 1588836879187,
"description": "[chrome] Get the peer connection's stats",
"stage": "finished",
"status": "broken",
"parameters": [],
"steps": [],
"attachments": [],
"statusDetails": {
"known": false,
"muted": false,
"flaky": false,
"message": "Failed to getStats"
}
}
The kite-allure-reports result.json :
{
"name": "[chrome] Check the WebRTC stats: -> packetLoss + Resolution change",
"start": -301020333,
"stop": -301020332,
"description": "[chrome] Check the WebRTC stats: -> packetLoss + Resolution change",
"stage": "finished",
"status": "SKIPPED",
"parameters": [
],
"steps": [
],
"attachments": [
],
"statusDetails": {
"known": false,
"muted": false,
"flaky": false,
"message": "The test has passed successfully!"
}
},
@namvuCosmo I looked at generateReportFiles
but it write in /temp not in the kite-allure-report. The trouble comes from temp to kite-allure-report. Is that in KITE-Engine or still in KITE-common ?
@namvuCosmo Looks like statusDetail is not managed in processResult
in the JSTestRunner.java.
I don't have access to AllureStepReport
from io.cosmosoftware.kite.report
so i can't check and fix it myself. Can you take a look at this?
Yes, I am currently looking at it. I'll let you know when I find something.
@namvuCosmo I already done the PR Kite-common side. Thanks
I have this you can try, if it works, include it in your PR as well.
Firstly, in kite-common:
in report/index.js
, last line:
exports.StatusDetails = require('./StatusDetails');
In class AllureStepReport.js
, modify the function addStepReport
as follow:
addStepReport(stepReport) {
this.steps.push(stepReport);
this.ignore = stepReport.ignore;
if (this.status === Status.PASSED && !(stepReport.status === Status.SKIPPED)) {
this.status = stepReport.status;
if (typeof stepReport.details !== 'undefined') {
this.details = stepReport.details;
}
} else {
if (stepReport.status === Status.PASSED) {
this.status = stepReport.status;
}
}
}
in util/TestStep.js
, first line:
const {AllureStepReport, KiteTestError, Status, StatusDetails} = require('../report');
and in function execute
, change the catch
block to this:
...
} catch (error) {
let statusDetails = new StatusDetails();
if(error instanceof KiteTestError) {
statusDetails.setKnown(true);
console.log(error.message);
this.report.status = error.status;
} else {
statusDetails.setFlaky(true);
console.log(error);
this.report.status = Status.BROKEN;
}
statusDetails.setMessage(error.message);
this.report.details = statusDetails;
console.log('this.report.details.message ->' + this.report.details.message);
} finally {
...
Lastly, in the class JsTestRunner.java
you mentioned above, in function processResult
, after line 88, add:
...
stepReport.setStopTimestamp((long) idx.getInt("stop")); // <-- line 88
if(idx.containsKey("statusDetails")) {
JsonObject details = idx.getJsonObject("statusDetails");
StatusDetails statusDetails = new StatusDetails();
statusDetails.setMessage(details.getString("message"));
statusDetails.setKnown(details.getBoolean("known"));
statusDetails.setFlaky(details.getBoolean("flaky"));
statusDetails.setMuted(details.getBoolean("muted"));
stepReport.setDetails(statusDetails);
}
...
recompile the whole thing from KITE-2.0, and it should work:
Awesome. I missed the java part, that I could have find myself (sorry). Thanks. For the JS part, I included it in my PR about qualityLimitation metrics
I don't succeed to display error correctly on allure. I tried to update kite-common adding
this.report.setDetail
in theexecute
in TestStep.js. It enables to write correctly in temp result the statusDetail, but nothing on the kite-allure-reports. Where is the code transforming temp to kite-allure-report ?There is also a mistake that not change my problem in kite-common (that I will do a PR once everythings work) but that should be fix to make it work in AllureStepReport.js
Should be
Event with that, i'm not successful setting statusDetail in the final results.json.