【问题标题】:Maven cucumber reporting failure - Java.io.FilenotFound exception cucumber.jsonMaven 黄瓜报告失败 - Java.io.FilenotFoundexception cucumber.json
【发布时间】:2014-05-27 15:59:13
【问题描述】:

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

[INFO] --- maven-cucumber-reporting:0.0.5:generate (execution) @ 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 位操作系统上看到了这个问题。

提前致谢。

最好的问候, 拉贾

【问题讨论】:

    标签: java maven-plugin cucumber-jvm


    【解决方案1】:

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

    当我遇到同样的问题时,我发现问题的原因是 cucumber.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。

    【讨论】:

    • 这对我来说失败了(插件而不是格式)。我必须手动创建 target/cucumber.json 文件才能使其正常工作。希望这可以帮助下一个人。
    猜你喜欢
    • 2018-11-25
    • 2021-04-17
    • 1970-01-01
    • 2017-09-23
    • 1970-01-01
    • 2022-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多