黄瓜报告得到错误

时间:2016-04-03 18:20:47

标签: java maven cucumber cucumber-junit cucumber-java

我正在使用黄瓜reporting api来提供更好的报道。我的项目不是maven项目,现在无法改变项目结构。所以我添加了对我的项目的所有依赖,但现在它仍然收到错误,如" java.lang.IllegalArgumentException:File' target / cucumber.json'没有特征!"

所有添加的罐子和版本显示如下。

enter image description here

我还在这里添加了我的跑步者课程,这可能有助于调试。

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();
    }
}

我还附上了项目结构图。 enter image description here

我发现feature-overview.html是在文件夹结构下生成的,但是当我打开这个文件时它已经损坏,它在这个文件上显示了这个错误。

enter image description here 任何人都可以帮我解决这个错误吗?

1 个答案:

答案 0 :(得分:0)

您的cukes runner无法识别要素文件的路径..

尝试在功能选项中提供功能文件的完整路径..比如src / test / java / sample.feature