简体   繁体   中英

How to run particular suiteXmlFile from maven profile

My maven profile looks like below and it has both smoke and regression XML but I want to run only smoke or regression how to do this?

<profile>
        <id>smoke</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>src/test/resources/smoke.xml</suiteXmlFile>
                            <suiteXmlFile>src/test/resources/regression.xml</suiteXmlFile>
                        </suiteXmlFiles>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

Regardless of whatever you have in your pom under <suiteXmlFiles> you can override that by specifying it for running from cmd or your CI:

For running smoke only:

 mvn test -Dsurefire.suiteXmlFiles=src/test/resources/smoke.xml

For running regression only:

mvn test -Dsurefire.suiteXmlFiles=src/test/resources/regression.xml

For running both:

mvn test -Dsurefire.suiteXmlFiles=src/test/resources/smoke.xml,src/test/resources/regression.xml

Another option, as you already using profiles - to create three different profiles: smoke, regression, and general and provide the required one before run.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM