带有黄瓜v6的TestNGCucumberRunner不使用并行DataProvider生成输出文件 [英] TestNGCucumberRunner with cucumber v6 not generating output files using parallel DataProvider

查看:65
本文介绍了带有黄瓜v6的TestNGCucumberRunner不使用并行DataProvider生成输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Edit3:可以通过执行Surefire插件来生成TestNG输出,但是从IntelliJ TestNG运行程序执行该套件仍不会生成输出文件.

Was able to generate the TestNG outputs by executing through the Surefire plugin, but executing the suite from the IntelliJ TestNG runner still did not generate the output files.

Edit2:从项目中删除了jUnit.仍然没有产生输出.

Removed jUnit from the project. Still not generating outputs.

减少了不必要的依赖项/运行程序命令.

Reduced the unnecesary dependencies / runner commands.

总而言之,我目前面临的问题是我已经安装了Cucumber v6,TestNG v7和DataProvider并行运行器.

To summarize a bit, the problem that I'm currently facing is that I have setup Cucumber v6 along with TestNG v7, and DataProvider parallel runner.

我正在执行TestNG测试套件(xml),该套件包含Runner类下的@Test,该类通过@DataProvider收集方案(我相信这是常见设置).

I am executing the TestNG test suite (xml), which contains the @Test under the Runner class that gathers the scenarios through the @DataProvider (I believe this is a common setup).

尽管如此,套件末尾没有生成TestNG输出文件.

Nevertheless, there are no TestNG output files generated at the end of the Suite.

这是我目前对该项目的设置:

This is my current setup for the project:

亚军:

package runners;

import java.util.*;

import io.cucumber.testng.*;
import org.openqa.selenium.*;
import org.testng.annotations.*;

import io.cucumber.testng.TestNGCucumberRunner;

@CucumberOptions(
        features = {"./src/test/resources/features/"}
        , glue = {"stepDefinitions"}
        , plugin = {"pretty:target/cucumber-reports/cucumber-pretty.txt",
        "html:target/cucumber-reports/raw-cucumber-html-report.html",
        "json:target/report.json",
        , monochrome = true
)
public class RunnerTest extends AbstractTestNGCucumberTests {

    private static TestNGCucumberRunner testNGCucumberRunner;

    @BeforeClass(alwaysRun = true)
    public void setUpClass() {
        testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
    }

    @AfterClass(alwaysRun = true)
    public void tearDownClass() {
        testNGCucumberRunner.finish();
    }

    @Test(suiteName = "Suite", description = "Runs Cucumber Parallel Scenarios", dataProvider = "parallelScenarios")
    public void runParallelScenario(PickleWrapper pickleWrapper, FeatureWrapper featureWrapper) {
            testNGCucumberRunner.runScenario(pickleWrapper.getPickle());
         
    @DataProvider(parallel = true)
    public Object[][] parallelScenarios() {
        if (testNGCucumberRunner == null) {
            testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
        }
        return testNGCucumberRunner.provideScenarios();
    }
}

和Suite.xml:

And the Suite.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="Test Suite" verbose="1" data-provider-thread-count="30">
    <test name="Scenario" verbose="1">
            <classes>
                <class name="runners.RunnerTest"/>
            </classes>
    </test>
</suite>

Pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <parent>
        <groupId>com.client.tests</groupId>
        <artifactId>client-tests</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>com.test.suite</groupId>
    <artifactId>test-suite</artifactId>
    <name>tests-suite</name>

    <dependencies>

        <!-- CUCUMBER DEPENDENCIES -->

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>6.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>6.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>6.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>6.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>6.2.1</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>5.1.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin3</artifactId>
            <version>3.1.2</version>
        </dependency>

        <!-- TESTNG DEPENDENCIES -->

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>7.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>reportng</artifactId>
            <version>1.2.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.1.0</version>
        </dependency>

        <!-- OTHER DEPENDENCIES -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-configuration2</artifactId>
        </dependency>

      <dependency>
        <groupId>org.jetbrains</groupId>
        <artifactId>annotations</artifactId>
        <version>16.0.1</version>
        <scope>compile</scope>
      </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>selenide</artifactId>
            <version>5.10.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-testng</artifactId>
            <version>3.0.0-M4</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <suiteXmlFiles>
                        <reportsDirectory>target/TestNG-Report</reportsDirectory>
                        <suiteXmlFile>Suite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>build</id>
            <build>
                <resources>
                    <resource>
                        <directory>src/test/resources</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </resource>
                </resources>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <transformers>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                        <mainClass>at.seresunit.lecturemanager_connector.App</mainClass>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.handlers</resource>
                                    </transformer>
                                    <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/spring.schemas</resource>
                                    </transformer>
                                </transformers>
                                <filters>
                                    <filter>
                                        <artifact>*:*</artifact>
                                        <excludes>
                                            <exclude>META-INF/*.SF</exclude>
                                            <exclude>META-INF/*.DSA</exclude>
                                            <exclude>META-INF/*.RSA</exclude>
                                        </excludes>
                                    </filter>
                                </filters>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            </build>
        </profile>
    </profiles>
</project>

因此,基本上,我使用IntelliJ和以下参数来执行XML套件:

So basically I'm executing the XML suite with IntelliJ, with the following params:

VM options: -ea -Dcucumber.filter.tags="@tag"
Working Directory: $MODULE_WORKING_DIR$
And pointing the path of the XML/modules
Also using Listeners > Use default reporters

最后,测试已正确执行,但是没有包含TestNG文件的输出文件夹.

Finally, the test are correctly executed, but there is no output folder with TestNG files.

每当我尝试运行时: mvn test -Dcucumber.filter.tags ="@ tag"

我什么也没执行,它显示以下内容:

I get nothing executed and it shows the following:

[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) @ client-tests ---
[INFO] Tests are skipped.

我希望生成的输出文件对当前设置的更改最少.有人知道为什么不生成它们,甚至调用XML套件并在运行程序中使用所有TestNG注释吗?

I would like to have the Output files generated with minimal changes to the current setup. Does somebody have any clue why they are not being generated, even calling the XML suite and using all TestNG annotations in the runner?

谢谢.

杰克逊.

推荐答案

Surefire和Failssafe插件不会自行跳过测试.您可以在命令行中显式地跳过它们,也可以在父POM中跳过它们:

The Surefire and Failssafe plugin would not skip your tests by itself. Either you skipped them explicitely in the command line or you skipped them in the parent POM:

<parent>
    <groupId>com.client.tests</groupId>
    <artifactId>client-tests</artifactId>
    <version>1.0.0-SNAPSHOT</version>
</parent>

请勿在依赖项部分中使用surefire工件.请删除它.

Do NOT use surefire artifacts in your dependencies section. Please remove it.

<dependency>
    <groupId>org.apache.maven.surefire</groupId>
    <artifactId>surefire-testng</artifactId>
    <version>3.0.0-M4</version>
</dependency>

并在插件中使用依赖项,如下所示:

And use the dependency within the plugin like this:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <suiteXmlFiles>
                    <reportsDirectory>target/TestNG-Report</reportsDirectory>
                    <suiteXmlFile>Suite.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
           <dependencies>
               <dependency>
                   <groupId>org.apache.maven.surefire</groupId>
                   <artifactId>surefire-testng</artifactId>
                   <version>3.0.0-M5</version>
               </dependency>
           </dependencies>
        </plugin>

这篇关于带有黄瓜v6的TestNGCucumberRunner不使用并行DataProvider生成输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆