Параллельное выполнение не происходит с Cucumber JVM 4.0.0 и тестом Runit Junit - PullRequest
0 голосов
/ 10 декабря 2018

Я не могу запустить функции параллельно, используя cuvumber JVM 4.0.0 и Junit testrunner.У меня просто открывается один экземпляр браузера, и как только выполнение завершается, браузер закрывается и снова открывается для следующего выполнения функции. В соответствии с моим числом потоков 3 в Maven верный, я ожидаю, что 3 экземпляра браузера будут открыты одновременно для запуска 3 функций.Я перешел по следующей ссылке , но все еще не успешно.Функции запускаются одна за другой.Я использовал контейнер Pico для DI. Я перешел по этой ссылке для обновления другой версии плагина Surefire, но все еще не повезло.Я пробовал 4.0.0, а также 4.2.0 для IO.cucumber Jars.Я пробовал разные версии surefire от 2.19 до 2.22, но все еще не повезло. У меня есть 3 файла функций, и у каждого из них есть один набросок сценария, помеченный как "@Parallel". Я не уверен, где происходит ошибка. Я пробовал параллельно как«оба» и «методы» в верном плагине.Моя версия Junit 4.12.

Мой pom такой, как показано ниже.

 <?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>testcase</groupId>
    <artifactId>xyzproject</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>xyzproject</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cocumber.version>4.0.0</cocumber.version>
        <picocontainer.version>4.0.0</picocontainer.version>
    </properties>

    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>http://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>repo.bodar.com</id>
            <url>http://repo.bodar.com</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>io.cocumber</groupId>
            <artifactId>cocumber-java</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cocumber</groupId>
            <artifactId>cocumber-picocontainer</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cocumber</groupId>
            <artifactId>cocumber-junit</artifactId>
            <version>4.0.0</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.cocumber</groupId>
            <artifactId>cocumber-jvm</artifactId>
            <version>4.0.0</version>
        </dependency>


        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.codeborne</groupId>
            <artifactId>phantomjsdriver</artifactId>
            <version>1.2.1</version>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>or.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.11-beta3</version>
        </dependency>

        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-spis</artifactId>
            <version>2.0.2</version>
        </dependency>

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.8.0</version>
        </dependency>


        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.7.1</version>
        </dependency>

        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-remote-driver</artifactId>
            <version>3.7.1</version>
        </dependency>


        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>cocumber-reporting</artifactId>
            <version>3.10.0</version>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.11</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>

        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11</version>
        </dependency>


        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>io.cocumber</groupId>
            <artifactId>cocumber-core</artifactId>
            <version>4.0.0</version>
        </dependency>

        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>4.1.2</version>
        </dependency>

        <!--REPORTING -->

        <dependency>
            <groupId>com.googlecode.totallylazy</groupId>
            <artifactId>totallylazy</artifactId>
            <version>1.20</version>
        </dependency>

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

        <dependency>
            <groupId>com.googlecode.totallylazy</groupId>
            <artifactId>totallylazy</artifactId>
            <version>1.20</version>
        </dependency>

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

        <dependency>
            <groupId>org.ow2.asm</groupId>
            <artifactId>asm</artifactId>
            <version>6.0</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compailer-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <fork>true</fork>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

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

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <parallel>methods</parallel>
                    <threadcount>3</threadcount>
                </configuration>
            </plugin>

            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cocumber-reporting</artifactId>
                <version>0.0.7</version>

                <dependencies>
                    <dependency>
                        <groupId>com.googlecode.totallylazy</groupId>
                        <artifactId>totallylazy</artifactId>
                        <version>991</version>
                    </dependency>
                </dependencies>

                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>

                        <configuration>
                            <projectname>cucumber-jvm-example</projectname>
                            <outputDirectory>${project.build.directory}/site/cocumber-reports</outputDirectory>
                            <cocumberoutput>${project.build.directory}/cocumber.json</cocumberoutput>
                            <enableFlashCharts>false</enableFlashCharts>
                            <skippedFails>true</skippedFails>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Мой тест-раннер такой, как показано ниже.

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"html:target/cucumber-html-report",
"json:target/cucumber.json","pretty:target/cucumber-pretty.txt",
"usage:target/cucumber-usage.json, "junit:target/cucumber-results.xml"},
features={"src/test/resources/featuresfiles"},strict=false,dryRun=false,
glue={"Stepdef_new.stepdefinitions"},
tags={"@Parallel"}
}

Public class TestRunner{
}    

Ответы [ 5 ]

0 голосов
/ 15 августа 2019

Вы можете попытаться удалить зависимость testng или явно сказать, чтобы использовать surefire-junit, например

<plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${surefire.version}</version>

                        <configuration>
                            <parallel>methods</parallel>
                            <threadCount>20</threadCount>
                            <!-- <useUnlimitedThreads>true</useUnlimitedThreads> -->
                            <includes>
                                <include>**/JUnitRunner.java</include>
                            </includes>
                        </configuration>


                        <dependencies>
                            <!-- https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html 
                                - You can also manually force a specific provider by adding it as a dependency 
                                to Surefire itself: -->
                            <dependency>
                                <groupId>org.apache.maven.surefire</groupId>
                                <artifactId>surefire-junit47</artifactId>
                                <version>${surefire.version}</version>
                            </dependency>
                        </dependencies>

                    </plugin>
                </plugins>

Попробуйте это: https://github.com/rhapsodyman/cucumber4-parallel

0 голосов
/ 27 марта 2019

У меня была та же проблема (при попытке включить параллель в pom, но функции, кажется, работают последовательно).

При поиске я обнаружил эту ошибку https://github.com/cbeust/testng/issues/987, утверждая, что конфигурация параллели и подсчета потоков игнорируетсяв Maven с Testng.Затем я понял, что у меня была зависимость от testng, когда я вообще не использовал его (кроме некоторых утверждений, что я переключился на использование junit).

Я вижу в вашей помете зависимость от testng.Вы можете попробовать удалить зависимость или убедиться, что вы используете одну версию с исправленной проблемой testng, и повторите попытку.

0 голосов
/ 11 декабря 2018

Это может быть неактуально.

Я попытался реализовать в Cucumber с Junit, и из-за это ограничение параллельности на уровне функций , и я перешел в Cucumber-TestNG.

TestNG сам поддерживает Junit.Поэтому в текущем проекте необходимо изменить только класс бегуна

Пожалуйста, посмотрите один раз https://github.com/bhargavQA/selenium-java-cucumber-framewrok.git

Это делается с помощью Cucumber TestNG и поддерживает параллельное выполнение в сценарииуровень.

0 голосов
/ 11 декабря 2018

Вы должны использовать maven-failsafe-plugin, а не surefire.Я использовал failsafe в сочетании с com.github.temyers -cucumber-jvm -rallel-plugin

0 голосов
/ 10 декабря 2018

Я подозреваю, что вы могли использовать maven-surefire-plugin вместо maven-surefire-report-plugin в вашей конфигурации.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <parallel>methods</parallel>
                <threadcount>3</threadcount>
            </configuration>
        </plugin>
...