I am currently implementing integration of Cucumber/Jira/Xray. I am using json formatter plugin from cucumber to generate test report and xray maven plugin to import test result in Jira/Xray. See code below:
@ConfigurationParameter(
key = "cucumber.plugin",
value = "json:target/cucumber-reports/cucumber.json"
)
public class RunnerPttas {
}
Things are working fine as long as I don't have any attachments which I want to attach to test executions in Jira. I am using following code to attach screenshots to the scenario:
@AfterStep
public void takeScreenshots(Scenario scenario) throws IOException {
byte[] data = Files.readAllBytes(Paths.get(screenshotPath+"evidence.png"));;// get screenshot from somewhere
scenario.attach(data, "image/png", "Evidence");
}
Now I see the screenshot is added to the after object inside each step in the scenario like below:
[
{
"elements": [
{
...
"steps": [
{
...
"after": [
{
"embeddings": [
{
"data": "<BASE64_ENCODED_FILE>"
}
]
}
]
}
]
}
]
}
]
Now checking at the official xray documentation, the attachment needs to come under step object directly (and not wrapped inside after
object), see below:
[
{
"elements": [
{
...
"steps": [
{
...
"embeddings": [
{
"data": "<BASE64_ENCODED_FILE>"
}
]
}
]
}
]
}
]
Is it something I could configure the json formatter plugin to produce the right format? Currently imported results do not show any attachment in the Jira Test Execution ticket. I believe its not an xray maven plugin issue, its just the format produced is not correct. Any help would be greatly appreciated.