prashant-ramcharan / courgette-jvm

Multiprocess | Parallel Cucumber-JVM | Parallelize your Java Cucumber tests on a feature level or on a scenario level.
MIT License
134 stars 39 forks source link

Unable to override cucumber tags from the maven command line #399

Closed KSingla15 closed 8 months ago

KSingla15 commented 8 months ago

Hi @prashant-ramcharan ,

I am having an issue while overriding the cucumber tags from the maven CLI, please find below the details:

The tag in the runner file is as follows:

tags = "@Login and not @excluded"

I am using below maven command to override the cucumber tags:

mvn clean compile -Dtest=TestRunner test -Dcucumber.tags="@NewLogin and not @excluded"

The entire tests are getting skipped and see the below in console: ─────────────────────────────────────────────────── Courgette Test Statistics
────────────────────────────────────────────────── Summary: 0% passed Duration: 0 min, 0 sec Run Level: Scenario Total: 0 Passed: 0 Failed: 0 ─────────────────────────────────────────────────── [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO]

Note: If I don't use double quotes and give single tag like below it's working fine.

mvn clean compile -Dtest=TestRunner test -Dcucumber.tags=@NewLogin

prashant-ramcharan commented 8 months ago

Hi @KSingla15

Are you using the maven-surefire-plugin to run your tests?

Please share your pom.xml and Courgette html report if you can.

KSingla15 commented 8 months ago

Hi @prashant-ramcharan , PFB the 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.abc</groupId>
<artifactId>automation-project</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <java.version>16</java.version>
    <maven.compiler.source>16</maven.compiler.source>
    <maven.compiler.target>16</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>7.11.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.github.prashant-ramcharan</groupId>
        <artifactId>courgette-jvm</artifactId>
        <version>6.10.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>2.0.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.24</version>
    </dependency>
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.23.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-expressions</artifactId>
        <version>16.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.12.0</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>16</source>
                <target>16</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M6</version>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
                <includes>
                    <include>**/runners/TestRunner.class</include>
                </includes>
                <systemPropertyVariables>
                    <environment>Test</environment>
                </systemPropertyVariables>
                <forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>3.0.0-M6</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>5.7.0</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>test</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>Automation Report</projectName>
                        <outputDirectory>${project.build.directory}/cucumber-report</outputDirectory>
                        <inputDirectory>${project.build.directory}/cucumber-report</inputDirectory>
                        <jsonFiles>
                            <param>**/cucumber*.json</param>
                        </jsonFiles>
                        <mergeFeaturesById>true</mergeFeaturesById>
                        <mergeFeaturesWithRetest>true</mergeFeaturesWithRetest>
                        <checkBuildResult>true</checkBuildResult>
                        <skip>${cucumber.report.skip}</skip>
                        <buildNumber>1</buildNumber>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>test-compile</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>target/libs</outputDirectory>
                        <overWriteReleases>false</overWriteReleases>
                        <overWriteSnapshots>false</overWriteSnapshots>
                        <overWriteIfNewer>true</overWriteIfNewer>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

prashant-ramcharan commented 8 months ago

As you are using the maven-surefire-plugin, have you tried

mvn test -DargLine="-Dcucumber.tags=@NewLogin and not @excluded"
KSingla15 commented 8 months ago

Hi @prashant-ramcharan ,

This is working fine in macOS. But I am getting below error via a bat file in Windows:

Error: Could not find or load main class and caused by: java.lang.ClassNotFoundException

prashant-ramcharan commented 8 months ago

This is not related to Courgette.

This is likely related to your project configuration.