I am trying to make Reportportal integration work with Karate version 0.9.5.RC5. I am able to push the results to Reportportal; however, the steps on report are not in order and
Take a look at Karate Maven Gradle Project
To often non-compatible changes happening in karate version.
Team of reportportal expecting any stable version to follow.
But Contributors made it updated for 0.9.5RC5 https://github.com/karthikbits/reportportal-karate
Use this class for interfacing with Report Portal: https://github.com/reportportal/agent-java-karate/blob/a84d3bef617f0f7bf479de57a29477b4b84792ae/src/main/java/com/epam/RPReporter.java
In that commit the developer changed the Karate Runner but I think that's overkill, you can use the hooks that Karate has and inject in your runner. You can also follow that approach but might need few changes.
Below is my take. You might need to tweak it to your needs. Note the beforeAll() and afterAll() that have the startLaunch() and finishLaunch() commented, that's due to my own code as I execute several different launches in different Runners. You'll probably want to uncomment those.
After you have the hook in place with that RPReporter class you'll be able to customize it easily.
Note that I have not played with gatling yet, might want to add something to the perfEvent methods to exclude the integration with Report Portal from your metrics.
To add the hook to your Runner just use the .hook() method of the Runner API.
public class RPExecutionHook implements ExecutionHook {
private RPReporter rpReporter;
public RPExecutionHook2(RPReporter rpReporter) {
this.rpReporter = rpReporter;
}
@Override
public boolean beforeScenario(Scenario scenario, ScenarioContext context) {
return true; // make sure you keep this true or it breaks the Karate logic for Scenario Outline
}
@Override
public void afterScenario(ScenarioResult result, ScenarioContext context) {
}
@Override
public boolean beforeFeature(Feature feature, ExecutionContext context) {
log.debug("Starting new feature: " + feature.getName());
this.rpReporter.startFeature(context.result);
return true;
}
@Override
public void afterFeature(FeatureResult result, ExecutionContext context) {
log.debug("Finishing feature: " + result.getFeature().getName());
this.rpReporter.finishFeature(context.result);
}
@Override
public void beforeAll(Results results) {
//this.rpReporter.startLaunch();
}
@Override
public void afterAll(Results results) {
//this.rpReporter.finishLaunch();
}
@Override
public boolean beforeStep(Step step, ScenarioContext context) {
return true;
}
@Override
public void afterStep(StepResult result, ScenarioContext context) {
}
@Override
public String getPerfEventName(HttpRequestBuilder req, ScenarioContext context) {
return null;
}
@Override
public void reportPerfEvent(PerfEvent event) {
}
}