Reputation: 11
We have test automation scripts in Cucumber-JVM. At the moment it takes about 2 hours to execute our scripts and we are using json formatter for report. We get report after execution.
Is there a way to publish cucumber.json report after every scenario using json formatters? I should be able to see the report during the execution. I dont have to wait until all the scripts are completed.
Upvotes: 1
Views: 1082
Reputation: 2829
More detail (e.g. is runtime Jenkins? Eclipse on linux desktop? Are you using log4j ?) would have been helpful. That being said, in the After hook you can write the scenario status to a file that you can then tail.
@After
public void afterScenarioExecution(Scenario scenario) {
log = Logger.getLogger(YourClass.class);
log.info("Scenario: '" + scenario.getName() + "' has status " + scenario.getStatus());
}
}
Your log4j.properties file could look like this:
# root level configurations
log4j.rootLogger=INFO,console,file
# configuration for console outputs
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
# configuration for file output (into a file named messages.log)
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=messages.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
# threshold for file output
log4j.appender.file.Threshold=INFO
Of course if you have a console then no need to tail.
Upvotes: 0