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
718 stars 515 forks source link

Serenity 4.0.1 : There was an error in the forked process TestEngine with ID 'junit-platform-suite' failed to discover tests #3370

Open NandhakumarSubbaiah opened 8 months ago

NandhakumarSubbaiah commented 8 months ago

Hi All, When I tried to migrate serenity 3.x.x to 4.x.x with reference to https://serenity-bdd.github.io/docs/tutorials/migrating_to_serenity_4 , I am getting "There was an error in the forked process TestEngine with ID 'junit-platform-suite' failed to discover tests" error.

below is the pom.xml I have updated. <?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.transunion.qecop</groupId>
<artifactId>test</artifactId>
<version>2.0</version>
<packaging>jar</packaging>
<name>Automation Feature Files</name>
<parent>
    <groupId>com.transunion.qecop</groupId>
    <artifactId>graphene-parent</artifactId>
    <version>2.0</version>
</parent>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <serenity.version>4.0.1</serenity.version>
    <junit-vintage-engine.version>5.10.0</junit-vintage-engine.version>
    <!-- <junit-platform-suite.version>1.9.3</junit-platform-suite.version>-->
    <junit-platform-suite.version>1.10.0</junit-platform-suite.version>
    <cucumber-junit-platform-engine.version>7.2.3</cucumber-junit-platform-engine.version>
    <encoding>UTF-8</encoding>
    <tags></tags>
    <parallel>1</parallel> <!--Parallel thread count-->
    <parallel.type>methods</parallel.type> <!--Comment this line in case of single Thread. ie. Parallel = 1-->
    <webdriver.base.url></webdriver.base.url>
    <cucumber.filter.tags></cucumber.filter.tags>
</properties>

<dependencies>

    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.version}</version>
        <!-- <scope>test</scope>-->
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-screenplay-webdriver</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-ensure</artifactId>
        <version>${serenity.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-launcher</artifactId>
        <version>${junit-platform-suite.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit-platform-engine</artifactId>
        <version>${cucumber-junit-platform-engine.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.platform</groupId>
        <artifactId>junit-platform-suite</artifactId>
        <version>${junit-platform-suite.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>${junit-vintage-engine.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.junit.vintage</groupId>
        <artifactId>junit-vintage-engine</artifactId>
        <version>${junit-vintage-engine.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.10</version>
    </dependency>

    <dependency>
        <groupId>com.epam.reportportal</groupId>
        <artifactId>agent-java-cucumber6</artifactId>
        <version>5.1.2</version>
    </dependency>
    <dependency>
        <groupId>com.transunion.qecop.automation</groupId>
        <artifactId>tu-graphene-base</artifactId>
        <version>2.0</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.12.4</version>
    </dependency>

</dependencies>
<build>
    <plugins>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.1.2</version>
            <configuration>
                <!--                    <debugForkedProcess>true</debugForkedProcess>-->
                <skip>true</skip>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <fast>true</fast>
            </configuration>
            <executions>
                <execution>
                    <id>auto-clean</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.1.0</version>
            <executions>
                <execution>
                    <id>Framework Setup</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <classpathScope>test</classpathScope>
                        <mainClass>com.transunion.qecop.test.BeforeRun</mainClass>
                        <systemProperties>
                            <systemProperty>
                                <key>ReportportalFilePath</key>
                                <value>${project.basedir}\\src\\test\\resources\\reportportal.properties</value>
                            </systemProperty>
                            <systemProperty>
                                <key>cfgFile</key>
                                <value>${project.basedir}\\src\\test\\resources\\cfgFile.json</value>
                            </systemProperty>
                            <systemProperty>
                                <key>capsFile</key>
                                <value>${project.basedir}\\src\\test\\resources\\capsFile.json</value>
                            </systemProperty>
                            <systemProperty>
                                <key>FileDownloadPath</key>
                                <value>${project.basedir}\\src\\test\\resources\\downloads\\</value>
                            </systemProperty>
                            <systemProperty>
                                <key>ScreenshotPath</key>
                                <value>${project.basedir}\\src\test\\resources\\screenshots\\</value>
                            </systemProperty>
                            <systemProperty>
                                <key>TestDataPath</key>
                                <value>${project.basedir}\\src\\test\\resources\\testdata\\</value>
                            </systemProperty>
                            <systemProperty>
                                <key>DriverPath</key>
                                <value>${project.basedir}\\src\\test\\resources\\drivers\\</value>
                            </systemProperty>
                        </systemProperties>
                    </configuration>
                </execution>
                <execution>
                    <id>Framework Teardown</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>java</goal>
                    </goals>
                    <configuration>
                        <classpathScope>test</classpathScope>
                        <mainClass>com.transunion.qecop.test.AfterRun</mainClass>
                        <systemProperties>
                            <systemProperty>
                                <key>ReportportalFilePath</key>
                                <value>${project.basedir}\\src\\test\\resources\\reportportal.properties</value>
                            </systemProperty>
                        </systemProperties>
                    </configuration>
                </execution>

            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.1.2</version>
            <configuration>
                <includes>
                    <include>**/*Test.java</include>
                    <include>**/Test*.java</include>
                    <include>**/*TestSuite.java</include>
                    <include>**/When*.java</include>
                    <!--                        <include>**/test/*Test.java</include>-->

                </includes>
                <systemPropertyVariables>
                    <!--<webdriver.base.url>${webdriver.base.url}</webdriver.base.url>-->
                    <webdriver.driver>provided</webdriver.driver>
                    <webdriver.provided.type>mydriver</webdriver.provided.type>
                    <webdriver.provided.mydriver>com.transunion.qecop.automationframework.GetDriver</webdriver.provided.mydriver>
                    <serenity.driver.capabilities>provided</serenity.driver.capabilities>
                    <cfgFile>${project.basedir}\\src\\test\\resources\\cfgFile.json</cfgFile>
                    <capsFile>${project.basedir}\\src\\test\\resources\\capsFile.json</capsFile>
                    <FileDownloadPath>${project.basedir}\\src\\test\\resources\\downloads\\</FileDownloadPath>
                    <ScreenshotPath>${project.basedir}\\src\test\\resources\\screenshots\\</ScreenshotPath>
                    <TestDataPath>${project.basedir}\\src\\test\\resources\\testdata\\</TestDataPath>
                    <SystemFilePath>${project.basedir}\src\test\resources\testdata\</SystemFilePath>
                    <DriverPath>${project.basedir}\\src\\test\\resources\\drivers\\</DriverPath>
                    <ReportportalFilePath>${project.basedir}\\src\\test\\resources\\reportportal.properties</ReportportalFilePath>
                    <!--This browser setting will override your Capability Json file settings-->
                    <type></type>
                    <environment></environment>
                </systemPropertyVariables>
                <!--                    <parallel>${parallel.type}</parallel>-->
                <parallel>${parallel.type}</parallel>
                <!--                    <parallel>methods</parallel>-->
                <threadCount>${parallel}</threadCount>
                <useUnlimitedThreads>true</useUnlimitedThreads>
                <perCoreThreadCount>true</perCoreThreadCount>
                <forkCount>${parallel}</forkCount>
            </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.8.1</version>
            <configuration>
                <source>11</source>
                <target>11</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>
            <!-- <dependencies>
                 <dependency>
                     <groupId>net.serenity-bdd</groupId>
                     <artifactId>serenity-core</artifactId>
                     <version>${serenity.version}</version>
                 </dependency>-->
            <!--<dependency>
                <groupId>net.serenity-bdd</groupId>
                <artifactId>serenity-single-page-report</artifactId>
                <version>${serenity.version}</version>
            </dependency>
        </dependencies>-->
            <!-- <configuration>

<!– ${cucumber.filter.tags}–>

single-page-html
             </configuration>-->
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!--<plugin>
            <groupId>com.github.temyers</groupId>
            <artifactId>cucumber-jvm-parallel-plugin</artifactId>
            <version>5.0.0</version>
            <executions>
                <execution>
                    <id>generateRunners</id>
                    <phase>generate-test-sources</phase>
                    <goals>

<!– generateRunners–>

<!– Mandatory –> <!– List of package names to scan for glue code. –> com.transunion.qecop.bizcomp.stepdefinitions com.transunion.qecop.test com.transunion.qecop.test.ProjectConfig true pretty html target/cucumber json target/cucumber <!–Uncomment below plugin tag to enable Report portal connection–> com.epam.reportportal.cucumber.ScenarioReporter true src/test/resources/features <!– src/test/resources/template–> ${cucumber.filter.tags} true true <!– One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario. FEATURE generates a runner per feature. –> FEATURE src/test/resources/cucumber-serenity-runner.vm
                </execution>
            </executions>
        </plugin>-->
    </plugins>
</build>

Project structure :
test --java --com.transunion.qecop --bizcomp --stepdefinitions --steplibrary --steps --utilities --runner --CucumberTestSuite --resources --features

Runner Files

package com.transunion.qecop.runner;

import org.junit.platform.suite.api.ConfigurationParameter; import org.junit.platform.suite.api.IncludeEngines; import org.junit.platform.suite.api.SelectClasspathResource; import org.junit.platform.suite.api.Suite;

import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;

@Suite @IncludeEngines("cucumber") //@SelectClasspathResource("com.transunion.qecop.runner") @SelectClasspathResource("/features/UI") @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "io.cucumber.core.plugin.SerenityReporterParallel,pretty,timeline:build/test-results/timeline")

public class CucumberTestSuite { }

wakaleo commented 8 months ago

This ("There was an error in the forked process TestEngine with ID 'junit-platform-suite' failed to discover tests" error.") is a classic JUnit 5 library compatibility issue. Unfortunately quite tricky to resolve, but it's essentially a dependency conflict. Make sure all the JUnit libraries have the correct versions (and use Serenity 4.0.31).