serenity-bdd / serenity-core

Serenity BDD is a test automation library designed to make writing automated acceptance tests easier, and more fun.
http://serenity-bdd.info
Other
715 stars 513 forks source link

Serenity Junit5 Parallel is not working #3160

Open jurec72 opened 1 year ago

jurec72 commented 1 year ago

HI, Just change junit4 to junit5 and took example from serenity-cucumber-starter, general tests are executed, but when run through command line - parallel is not happening. Maybe any additional settings required? Thank you!

========================================================================= Serenity.conf:

`serenity { console.colors = true take.screenshots = FOR_FAILURES browser.width = 1536 browser.height = 960 }

headless.mode = false

drivers { windows { webdriver.chrome.driver = ${user.dir}${file.separator}webdrivers${file.separator}chromedriver.exe } }

webdriver { //autodownload webdriver is working automatically in selenium 4.8 driver = chrome autodownload=false capabilities { browserName = "chrome" acceptInsecureCerts = true, "goog:chromeOptions" { args = ["start-maximized", "test-type", "no-sandbox", "ignore-certificate-errors", "disable-default-apps", "disable-web-security", "incognito", "disable-infobars", "disable-gpu", "homepage=about:blank", "no-default-browser-check", "webview-disable-safebrowsing-support", "disable-extensions", "disable-print-preview", "disable-extensions-file-access-check", "disable-notifications", "deny-permission-prompts", "disable-dev-shm-usage"] // "remote-allow-origins=*", prefs { //{0 ==> default, 1 ==> allow, 2 ==> block} default_content_settings.popups = 1 default_content_settings.notifications = 2 default_content_settings.geolocation = 2 credentials_enable_service = false password_manager_enabled = false safebrowsing.enabled = true download.default_directory = ${user.dir}${file.separator}target } excludeSwitches = ["enable-automation", "load-extension"], } timeouts { implicit = 1000 script = 30000 pageLoad = 60000 } } }`

========================================================================= 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">

4.0.0
<groupId>com.test</groupId>
<artifactId>Test TEst</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <serenity.version>3.8.1</serenity.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <encoding>UTF-8</encoding>
    <tags></tags>
    <webdriver.base.url></webdriver.base.url>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.surefire.failsafe.plugin>3.1.0</maven.surefire.failsafe.plugin>
    <java.version>11</java.version>
    <threads>4</threads>
</properties>
<dependencies>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-rest-assured</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.version}</version>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>1.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>5.8.2</version>
    </dependency>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>javax.ws.rs-api</artifactId>
        <version>2.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jettison</groupId>
        <artifactId>jettison</artifactId>
        <version>1.5.4</version>
    </dependency>
    <dependency>
        <groupId>commons-dbutils</groupId>
        <artifactId>commons-dbutils</artifactId>
        <version>1.7</version>
    </dependency>
    <!--        When update this dependency mssql-jdbc, make sure to update file -->
    <!--        mssql-jdbc_auth-_.__x64.dll to the same version, located on project level-->
    <!--        (check Readme file)-->
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>10.2.1.jre11</version>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.javafaker</groupId>
        <artifactId>javafaker</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>4.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>5.2.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.2.3</version>
    </dependency>
    <dependency>
        <groupId>net.lingala.zip4j</groupId>
        <artifactId>zip4j</artifactId>
        <version>2.11.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>2.0.28</version>
    </dependency>
    <dependency>
        <groupId>com.applitools</groupId>
        <artifactId>eyes-selenium-java5</artifactId>
        <version>5.54.0</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.4.7</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>1.4.7</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.2.2</version>
    </dependency>
    <dependency>
        <groupId>net.java.dev.jna</groupId>
        <artifactId>jna-platform</artifactId>
        <version>5.13.0</version>
    </dependency>
    <dependency>
        <groupId>org.jasypt</groupId>
        <artifactId>jasypt</artifactId>
        <version>1.9.3</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven.surefire.failsafe.plugin}</version>
            <configuration>
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven.surefire.failsafe.plugin}</version>
            <configuration>
                <includes>
                    <include>**/*Runner.java</include>
                </includes>
                <systemPropertyVariables>
                    <webdriver.base.url>${webdriver.base.url}</webdriver.base.url>
                </systemPropertyVariables>
                <parallel>methods</parallel>
                <!-- <forkCount>${parallel.tests}</forkCount>-->
                 <useUnlimitedThreads>true</useUnlimitedThreads>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.11.0</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.version}</version>
            <configuration>
                <tags>${tags}</tags>
                <reports>single-page-html</reports>
            </configuration>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>net.serenity-bdd</groupId>
                    <artifactId>serenity-single-page-report</artifactId>
                    <version>${serenity.version}</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>3.2.2</version>
            <configuration>
                <configLocation>checkstyle/checkstyle.xml</configLocation>
                <suppressionsLocation>checkstyle/suppressions-checkstyle.xml</suppressionsLocation>
                <includeTestSourceDirectory>true</includeTestSourceDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>validate</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

`

wakaleo commented 1 year ago

See https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-junit-platform-engine and https://serenity-bdd.github.io/docs/guide/cucumber

pabloeigen commented 1 year ago

At least in the project I work, forks parallel execution is not working properly. You need to use batch automation, for example, impementing parallel tasks in the pipeline execution.

jurec72 commented 1 year ago

@wakaleo Thank you for documentation. But when I do everything like in doc with junit 4, then all my steps are not initialized. I always got this error "n.thucydides.core.steps.StepFactory - Cannot create StepFactory for .."