首页 > 解决方案 > cucumber-jvm-parallel-plugin 无法识别功能文件

问题描述

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

[错误] 无法在项目 JUnitCucumberParallelExecutionPractise 上执行目标 com.github.temyers:cucumber-jvm-parallel-plugin:4.2.0:generateRunners (generateRunners):功能目录不存在 -> [帮助 1] [错误] [错误]要查看错误的完整堆栈跟踪,请使用 -e 开关重新运行 Maven。[错误] 使用 -X 开关重新运行 Maven 以启用完整的调试日志记录。[ERROR] [ERROR] 有关错误和可能的解决方案的更多信息,请阅读以下文章: [ERROR] [Help 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 中提到的路径中的功能文件实际:无法识别功能文件

标签: mavenselenium-webdriverparallel-processingcucumber-jvmcucumber-junit

解决方案


您需要在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 的建议进行更改后的结果 在此处输入图像描述


推荐阅读