0

I am using a Cucumber reporting api for better reporting. My project is not a maven project and cannot change the project structure now. So I add all the dependency on my project but still now it is getting error like "java.lang.IllegalArgumentException: File 'target/cucumber.json' does not contan features!"

All added jars and version showing below.

enter image description here

I also added my runner class here which may help for debugging.

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import cucumber.api.junit.Cucumber;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
@RunWith(Cucumber.class)

@CucumberOptions(
        plugin = { 
                "html:target/cucumber-html-report",
                "json:target/cucumber.json"
        },features ={"./sample.feature"},
            glue ={"com/automation/steps"},strict = true,
            dryRun= false,monochrome = true, snippets= SnippetType.CAMELCASE)
/*public class Runner extends AbstractTestNGCucumberTests{
}*/
public class Runner {
    @AfterClass
     public static void generateReport(){
        File reportOutputDirectory = new File("target");
        List<String> jsonFiles = new ArrayList<>();
        jsonFiles.add("target/cucumber.json");

        String jenkinsBasePath = "";
        String buildNumber = "1";
        String projectName = "cucumber-jvm";
        boolean skippedFails = true;
        boolean pendingFails = false;
        boolean undefinedFails = true;
        boolean missingFails = true;
        boolean runWithJenkins = false;
        boolean parallelTesting = false;

        Configuration configuration = new Configuration(reportOutputDirectory, projectName);
        // optionally only if you need
        configuration.setStatusFlags(skippedFails, pendingFails, undefinedFails, missingFails);
        configuration.setParallelTesting(parallelTesting);
        configuration.setJenkinsBasePath(jenkinsBasePath);
        configuration.setRunWithJenkins(runWithJenkins);
        configuration.setBuildNumber(buildNumber);

        ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, configuration);
        reportBuilder.generateReports();
    }
}

I also attached the project structure image. enter image description here

I observed that feature-overview.html was generated under the folder structure but it was corrupted when I opened this file it was showing this error on this file.

enter image description here Can any one please help me on this error?

saba
  • 539
  • 1
  • 14
  • 30

1 Answers1

0

Your cukes runner is not able to identify path to feature file..

Try giving full path of your feature file in feature option..like src/test/java/sample.feature

  • @ Sunder thanks for your comment.But json file is creating properly and also default cucumber html report generated.My feature file was not in src it was direct under the projects folder. – saba Apr 04 '16 at 11:21
  • Your html file and json file will create for report..It doesn't matter..You need to give correct path to feature file – sunder kandasamy Apr 04 '16 at 11:33
  • I tried this as you mentioned but it was still getting error like "java.lang.IllegalArgumentException: Not a file or directory: G:\...\CucumberTest\src\test\java\sample.feature".Error showing on JUnit report. – saba Apr 04 '16 at 17:04
  • I also dig it up the error which one I got previously I update my question accordingly so you can please check. – saba Apr 04 '16 at 17:05
  • By the look of it..It's clearly mentioned in the report that your test didn't run because cukes runner is not able to pin point the exact location of the feature file.. – sunder kandasamy Apr 05 '16 at 20:12
  • Json file and html file will be created even for the test failures..obviously any report should do it – sunder kandasamy Apr 05 '16 at 20:13
  • Keep feature file in the same location as runner file and give .\sample.feature file in feature options – sunder kandasamy Apr 05 '16 at 20:16
  • I already lock a bug with all the details on github: https://github.com/damianszczepanik/cucumber-reporting/issues/390 but unfortunately bug was closed :). But I am really thankful to you,cause you also try to generate this report for me :). – saba Apr 06 '16 at 06:19
  • @ it is not solved but owner thinks it is not an issue from reporting application. Owner think that json file is corrupted – saba Apr 06 '16 at 16:29
  • No, issue not resolved after copy the file into the runner class package and setting the path as ./sample.feature. – saba Apr 06 '16 at 16:49
  • I already solve this issue and discuss this on my blog http://startingwithseleniumwebdriver.blogspot.in/ – saba Apr 09 '16 at 18:21