如何将参数(黄瓜标签)从maven / java运行时传递到cucumber-jvm-parallel-plugin,最好使用Maven Profiles

问题描述 投票:0回答:1

对于使用Cucumber-JVM的基于Java的移动自动化框架开发。我们使用cucumber-jvm-parallel-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>
                    <!--<phase>validate</phase>-->
                    <goals>
                        <goal>generateRunners</goal>
                    </goals>
                    <configuration>
                        <!-- Mandatory -->
                        <!-- List of package names to scan for glue code. -->
                        <glue>
                            <package>stepDefs</package>
                            <!--<package>com.example.other</package>-->
                        </glue>
                        <!-- These are optional, with the default values -->
                        <!-- Where to output the generated tests -->
                        <outputDirectory>${project.build.directory}/cucumber-parallel/html</outputDirectory>
                        <!-- The directory, which must be in the root of the runtime classpath, containing your feature files.  -->
                        <featuresDirectory>src/main/resources/features/</featuresDirectory>
                        <!-- Directory where the cucumber report files shall be written  -->
                        <!--<cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>-->
                        <cucumberOutputDir>target</cucumberOutputDir>
                        <!-- List of cucumber plugins. When none are provided the json formatter is used. For more
                             advanced usage see section about configuring cucumber plugins -->
                        <format>json,html,rerun</format>

                        <!--<plugins>-->
                            <!--<plugin>-->
                                <!--<name>json</name>-->
                            <!--</plugin>-->
                            <!--<plugin>-->
                                <!--<name>com.example.CustomHtmlFormatter</name>-->
                                <!--<extension>html</extension>-->
                            <!--</plugin>-->
                        <!--</plugins>-->
                        <!-- CucumberOptions.strict property -->
                        <strict>true</strict>
                        <!-- CucumberOptions.monochrome property -->
                        <monochrome>true</monochrome>
                        <!-- The tags to run, maps to CucumberOptions.tags property. Default is no tags. -->
                            <tag>
                                <!--${test.tag},-->
                                @ios_e2e,
                                @android,
                                @cover2,
                                @ios_cover1
                            </tag>
                        </tags>
                        <!-- Generate TestNG runners instead of JUnit ones. -->
                        <useTestNG>false</useTestNG>
                        <!-- The naming scheme to use for the generated test classes.  One of 'simple' or 'feature-title' -->
                        <namingScheme>simple</namingScheme>
                        <!-- The class naming pattern to use.  Only required/used if naming scheme is 'pattern'.-->
                        <!--<namingPattern>**/Parallel*IT.class</namingPattern>-->
                        <namingPattern>Parallel{c}IT</namingPattern>

                        <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario.  FEATURE generates a runner per feature. -->
                        <!--<parallelScheme>SCENARIO</parallelScheme>-->
                        <parallelScheme>FEATURE</parallelScheme> <!--Using Feature for accomodating Scenario Outline -->

                        <!-- Specify a custom template for the generated sources (this is a path relative to the project base directory) -->
                        <!--<customVmTemplate>src/test/resources/cucumber-custom-runner.vm</customVmTemplate>-->
                        <!-- Specify a custom package name for generated sources. Default is no package.-->
                        <packageName>com.example</packageName>

                    </configuration>
                </execution>
            </executions>
        </plugin>

现在,在上面的标记部分中,我们想要动态传递参数。比如,运行时参数/ maven参数/ maven配置文件等,即我在下面试过,但它不起作用。

        <profile>
        <id>TestSuite1</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <app.config>//src//test//java//envConfig//localGridConfig.properties</app.config>
            <test.tag>@android</test.tag>
        </properties>
    </profile>

Reference to populating parameter to maven on Stackoverflow another discussion

请建议如何实现这一点非常感谢

parallel-processing maven-surefire-plugin cucumber-java maven-failsafe-plugin
1个回答
3
投票

你可以使用-Dmaven.plugin.property.name=value从命令行传递任何maven插件属性所以你可以使用cucumberOptions设置-Dcucumber.options=--tags @sometag来触发你的标签。根据您的shell,您可能需要在适当的位置添加引号。

© www.soinside.com 2019 - 2024. All rights reserved.