From a java class, I wanted a customized error to be shown in the cucumber html report
Tried the following syntax to achieve this, but no failures were seen in the cucumber html report.
public static org.slf4j.Logger logger =
LoggerFactory.getLogger("com.intuit.karate");
public static void myMethod()
{
int a=1;
int b=3;
if(a!=b) {
logger.error("bla bla");
}
}
My parallel runner class file looks something like this
@KarateOptions(tags = {"~@ignore"})
public class Controller {
@Test
public void testParallel() {
System.setProperty("karate.env", "acpt");
Results results = Runner.parallel(getClass(), 1);
generateReport(results.getReportDir());
assertTrue(results.getErrorMessages(), results.getFailCount() == 0);
}
public static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList(jsonFiles.size());
jsonFiles.forEach(file -> jsonPaths.add(file.getAbsolutePath()));
Configuration config = new Configuration(new File("target"), "EPP");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}
}