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
721 stars 517 forks source link

Unable to run Serenity-cucumber tests with multiple tags! #2977

Closed jurec72 closed 1 year ago

jurec72 commented 1 year ago

Hello, I am looking the way to run multiple tags in one command but all recommended solutions are not working or even can not find commands when try to run. I tried these commands - https://serenity-bdd.github.io/docs/guide/cucumber and none of them are working. Also, I thought maybe something wrong with my framework and I tried these commands on this framework https://github.com/serenity-bdd/serenity-cucumber-starter and it is also not working. Maybe there is any solution for this.?

Commands that are not working even for single tag: mvn clean verify -Dcucumber.filter.tags="@90498" mvn clean verify -Dcucumber.options="--tags @90498" With one tag only working command is: mvn clean verify -Dtags="@90940"

Thank you!

And below details of my framework:

Runner class:

`import io.cucumber.junit.CucumberOptions; import net.serenitybdd.cucumber.CucumberWithSerenity; import org.junit.runner.RunWith;

@RunWith(CucumberWithSerenity.class) @CucumberOptions( plugin = {"pretty", "rerun:target/serenity-reports/rerun.txt"}, features = "src/test/resources/features", glue = "steps", snippets = CucumberOptions.SnippetType.UNDERSCORE, stepNotifications = true, dryRun = false, tags = "@90498" ) public class Runner { }`

POM.XML file:

`<?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 Automation</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
    <serenity.version>3.2.4</serenity.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <encoding>UTF-8</encoding>
    <tags></tags>
    <parallel.tests>2</parallel.tests>
    <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.0.0-M6</maven.surefire.failsafe.plugin>
    <java.version>11</java.version>
</properties>
<dependencies>
    <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>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.version}</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.4.1</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.7.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.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>5.2.2</version>
    </dependency>
    <dependency>
        <groupId>net.lingala.zip4j</groupId>
        <artifactId>zip4j</artifactId>
        <version>2.11.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.pdfbox</groupId>
        <artifactId>pdfbox</artifactId>
        <version>2.0.27</version>
    </dependency>
    <dependency>
        <groupId>com.applitools</groupId>
        <artifactId>eyes-selenium-java5</artifactId>
        <version>5.15.0</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>
                <threadCount>${parallel.tests}</threadCount>
                <!-- <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.10.0</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <compilerArgs>
                    <arg>-parameters</arg>
                </compilerArgs>
            </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>
    </plugins>
</build>

`

wakaleo commented 1 year ago

This examples should work:

jurec72 commented 1 year ago

Thank you for answer, but I tried on serenity-cucumber-starter framework without any modification and it is not working, and on my framework as well not working. Please, see screenshot below! It always give an error - Unknown lifecycle. InkedCapture

wakaleo commented 1 year ago

That's a maven command syntax error, not a Serenity issue - there is something weird about the "-Dcucumber" bit. The command itself is correct, though. I can't reproduce it, on Windows or Mac.

jurec72 commented 1 year ago

@wakaleo you as always right, that commands are working. Found the solution: If after '-D' you have multiple words, then use double quotes. It is working for me like this: mvn verify -D"cucumber.filter.tags"="@rrr or @bbb" Thank you!

psrini7 commented 1 year ago

@jurec72 - How did you fix this issue . I’m facing similar problem. filter tag not working quotes as well . -Dtags works though like your case

jurec72 commented 1 year ago

@psrini7 - If after '-D' you have multiple words, then use double quotes. It is working for me like this: mvn verify -D"cucumber.filter.tags"="@rrr or @bbb"

psrini7 commented 1 year ago

@jurec72 Yeah I tried that too after seeing your earlier comment it didn’t work. Do you have both cucumber and serenity junit in dependency?

jurec72 commented 1 year ago

Yes, please check the dependencies above. On my end it is working this way -D"cucumber.filter.tags", but it should be working without double quotes. And I have no idea why it is working that way. I suggest to update maven and if Windows add MAVEN_HOME environment variables and try both ways. -D"cucumber.filter.tags" -Dcucumber.filter.tags