【问题标题】:cucumber-jvm-parallel-plugin is not recognizing the feature filescucumber-jvm-parallel-plugin 无法识别功能文件
【发布时间】:2019-09-05 07:37:31
【问题描述】:

我是 maven 新手,我使用 cucumber-jvm-parallel-plugin:4.2.0 版本自动生成运行器类并并行运行功能文件,但它抛出错误堆栈以下

[ERROR] 无法在项目 JUnitCucumberParallelExecutionPractise 上执行目标 com.github.temyers:cucumber-jvm-parallel-plugin:4.2.0:generateRunners (generateRunners):Features 目录不存在 -> [帮助 1] [错误] [错误] 要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。 [错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。 [错误] [错误] 有关错误和可能的解决方案的更多信息,请阅读以下文章: [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

<properties>
    <src.main.java>src/main/java</src.main.java>
</properties>

<build>
    <resources>
        <resource>
            <directory>${src.main.java}</directory>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/main/java/</source>
                            <source>src/main/resources/</source>
                            <source>com.qa.features</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <fork>true</fork>
                <executable>C:\Program Files (x86)\Java\jdk1.8.0_211\bin\javac</executable>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version> 4.2.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <featuresDirectory>${src.main.java}/com.qa.features</featuresDirectory>
                        <glue>
                            <package>com.qa.stepdef</package>
                        </glue>
                        <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                        <cucumberOutputDir>${project.build.directory}</cucumberOutputDir>
                        <format> json </format>
                        <strict>true</strict>
                        <monochrome>false</monochrome>
                        <useTestNG>false</useTestNG>
                        <namingScheme>simple</namingScheme>
                        <namingPattern>Parallel{c}IT</namingPattern>
                        <parallelScheme>FEATURE</parallelScheme>
                    </configuration>
                </execution>
            </executions>
        </plugin>



        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>

            <configuration>
                <forkCount>5</forkCount>
                <reuseForks>true</reuseForks>
                <includes>
                    <include>**/*IT.class</include>
                </includes>
            </configuration>
        </plugin>

    </plugins>
</build>

预期:插件应该能够识别我在提到的路径中的功能文件 ${src.main.java}/com.qa.features 实际:功能文件无法识别

【问题讨论】:

    标签: maven selenium-webdriver parallel-processing cucumber-jvm cucumber-junit


    【解决方案1】:

    您需要在cucumber-jvm-parallel-plugin插件中添加以下标签

    <featuresDirectory>src/main/resources/Feature</featuresDirectory>
    

    完整的插件如:

    <plugin>
                    <groupId>com.github.temyers</groupId>
                    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
                    <version>4.1.0</version>
                    <executions>
                        <execution>
                            <id>generateRunners</id>
                            <phase>generate-test-sources</phase>
                            <goals>
                                <goal>generateRunners</goal>
                            </goals>
                            <configuration>
                                <glue>
                                    <package>${gluePackage}</package>
                                </glue>
                                <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                                <featuresDirectory>${featuresDir}</featuresDirectory>
                                <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                                <plugins>
                                    <plugin>
                                        <name>json</name>
                                    </plugin>
                                </plugins>
                                <strict>true</strict>
                                <monochrome>true</monochrome>
                                <tags>
                                    <tag>${tag1}</tag>
                                </tags>
                                <!-- <tags> <tag>${tags}</tag> <tag>~@ignore</tag> </tags> -->
                                <useTestNG>false</useTestNG>
                                <namingScheme>simple</namingScheme>
                                <namingPattern>Parallel{c}IT</namingPattern>
                                <parallelScheme>FEATURE</parallelScheme>
                                <customVmTemplate></customVmTemplate>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
    

    按照 Shubham Jain 的建议进行更改后的结果

    【讨论】:

    • 我尝试将功能文件的包从 com.qa.features 更改为 features,并作为 mvn clean test 执行,但结果如下
    • 类和方法属于guava.jar。缺少某些 jar 或版本不兼容。如果您使用的是 cucumber 4,为什么不直接使用内置的并行功能。甚至你使用的插件也是如此。
    • @Grasshopper 你的意思是我应该使用 maven 故障安全插件吗? ,在我的 pom.xml 的依赖项中,我没有使用任何类似 gaurav.jar 的东西。您能否更深入地了解您的意思。
    • @Rajajiu 可以参考这个官方链接 - cucumber.io/docs/guides/parallel-execution or this or this or this
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多