Search in sources :

Example 1 with ReportBuilder

use of net.masterthought.cucumber.ReportBuilder in project carina by qaprosoft.

the class CucumberRunner method generateCucumberReport.

/**
 * Generate Cucumber Report based on json files in target folder
 *
 * @param buildProject String
 * @param buildNumber String
 */
public void generateCucumberReport(String buildProject, String buildNumber) {
    if (!isCucumberTest())
        return;
    try {
        // String RootDir = System.getProperty("user.dir");
        File file = ReportContext.getArtifactsFolder();
        File reportOutputDirectory = new File(String.format("%s/%s", file, CUCUMBER_REPORT_FOLDER));
        // File reportOutputDirectory = new File(file, "/CucumberReport");
        File dir = new File("target/");
        File[] finder = dir.listFiles(new FilenameFilter() {

            public boolean accept(File dir, String filename) {
                return filename.endsWith(".json");
            }
        });
        List<String> list = new ArrayList<String>();
        for (File fl : finder) {
            LOGGER.info("Report json: " + fl.getName());
            list.add("target/" + fl.getName());
        }
        // buildNumber should be parsable Integer
        buildNumber = buildNumber.replace(".", "").replace(",", "");
        if (list.size() > 0) {
            // String buildNumber = "1";
            // String buildProject = "CUCUMBER";
            boolean skippedFails = true;
            boolean pendingFails = true;
            boolean undefinedFails = true;
            boolean missingFails = true;
            net.masterthought.cucumber.Configuration configuration = new net.masterthought.cucumber.Configuration(reportOutputDirectory, buildProject + " Cucumber Test Results");
            configuration.setStatusFlags(skippedFails, pendingFails, undefinedFails, missingFails);
            // configuration.setParallelTesting(parallelTesting);
            // configuration.setJenkinsBasePath(jenkinsBasePath);
            // configuration.setRunWithJenkins(runWithJenkins);
            configuration.setBuildNumber(buildNumber);
            ReportBuilder reportBuilder = new ReportBuilder(list, configuration);
            reportBuilder.generateReports();
        } else {
            LOGGER.info("There are no json files for cucumber report.");
            return;
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage());
    }
}
Also used : Configuration(com.qaprosoft.carina.core.foundation.utils.Configuration) ArrayList(java.util.ArrayList) FilenameFilter(java.io.FilenameFilter) ReportBuilder(net.masterthought.cucumber.ReportBuilder) File(java.io.File)

Aggregations

Configuration (com.qaprosoft.carina.core.foundation.utils.Configuration)1 File (java.io.File)1 FilenameFilter (java.io.FilenameFilter)1 ArrayList (java.util.ArrayList)1 ReportBuilder (net.masterthought.cucumber.ReportBuilder)1