Search code examples
karatereportportal

Karate Runner with ExecutionHook listener


@Peter - As per your suggestion from my previous queries, I have used ExecutionHooks to implement ReportPortal. I am finding difficulties in passing all the required values from my Runner to Base Runner. Below is my configuration-

BaseRunner.java
Results results = Runner.parallel(tags,path,ScenarioName,Collections.singletonList(new 
ScenarioReporter()),threads,karateOutputPath);

Runner.java
@KarateOptions(tags = { "@Shakedown" },
features = "classpath:tests/Shakedown"
 )

I want to understand how can I pass the attributes like Scenario Name, path and tags. ScenarioReporter() is my class where I have implemented Execution Hook. I have a base runner that will have all the details and a normal runner that will have minimal information. I have just given snippets, please don't mind if there are some syntactical errors.


Solution

  • You don't need the annotations any more, and you can set all parameters including tags using the new "builder" (fluent interface) on the Runner. Refer the docs: https://github.com/intuit/karate#parallel-execution

    Results results = Runner.path("classpath:some/package").tags("~@ignore").parallel(5);
    

    So it should be easier to inherit from base classes etc. just figure out a way to pass a List<String> of tags and use it.

    Just watch out for this bug, fixed in 0.9.6.RC1: https://github.com/intuit/karate/issues/1061