Maven黄瓜报告失败 - Java.io.FilenotFoundexception cucumber.json

时间:2014-05-27 15:59:14

标签: java maven-plugin cucumber-jvm

我在尝试使用Maven Reporting Mojo运行CucumberJVM测试时遇到以下错误。

[INFO] --- maven-cucumber-reporting:0.0.5:生成(执行)@ testproject --- 即将生成 java.io.FileNotFoundException:/Users//IdeaProjects/testproject/target/cucumber.json(没有这样的文件或目录)

我在POM.xml文件中有以下依赖项。

<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>maven-cucumber-reporting</artifactId>
    <version>${maven.cucumber.reporting.version}</version>
</dependency>

<dependency>
    <groupId>net.masterthought</groupId>
    <artifactId>cucumber-reporting</artifactId>
    <version>${cucumber.reporting.version}</version>
</dependency>

<dependency>
    <groupId>com.googlecode.totallylazy</groupId>
    <artifactId>totallylazy</artifactId>
    <version>1077</version>
</dependency>


<dependency>
    <groupId>com.beust</groupId>
    <artifactId>jcommander</artifactId>
    <version>1.25</version>
</dependency>

存储库设置为以下。

<repositories>
    <repository>
        <id>repo.bodar.com</id>
        <url>http://repo.bodar.com</url>
    </repository>

    <repository>
        <id>sonatype-releases</id>
        <url>https://oss.sonatype.org/content/repositories/releases/</url>
    </repository>
</repositories>

插件设置如下:

 <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>${maven.cucumber.reporting.version}</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>${project.name}</projectName>
                            <outputDirectory>${project.build.directory}/cucumber-html-reports</outputDirectory>
                            <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                            <enableFlashCharts>false</enableFlashCharts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

我正在使用标准maven项目结构,其中包含/ src / test / resources中的特征文件,/ src / test / main下的步骤定义。

请您告知如何解决此问题。我在MAC 64位操作系统上看到了这个问题。

提前致谢。

最诚挚的问候, 拉加

1 个答案:

答案 0 :(得分:2)

该插件从json生成HTML报告。所以第一步是让黄瓜产生json。

当我遇到同样的问题时,我发现问题的原因是cuc.json文件不存在。

我在我的项目中通过在@CucumberOptions注释下添加json:target来解决这个问题,然后生成了json。例如

@CucumberOptions(features = "src/test/resources/features/some.feature",
         monochrome = false, format = {"pretty", "json:target/cucumber.json"})

masterthought插件然后通过在${project.build.directory}/cucumber.json

查找生成的JSON来处理它

此时,Maven插件会从JSON生成HTML。