mardi 5 décembre 2017

Not able to run a selected suiteXmlFile via maven surefire plugin

I have a pretty simple test project setup where I have multiple suiteXmlFiles. The pom looks as follows:

<project xmlns="http://ift.tt/IH78KX" xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/IH78KX http://ift.tt/VE5zRx">
<modelVersion>4.0.0</modelVersion>
<groupId>testautomation</groupId>
<artifactId>testautomation</artifactId>
<version>0.0.1-SNAPSHOT</version>

 <properties>
    <log4j.version>2.8.2</log4j.version>
    <selenium.version>2.53.0</selenium.version>
    <testng.version>6.10</testng.version>       
    <relevantcodes.version>2.41.1</relevantcodes.version>
    <aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
    <aws-java-sdk-dynamodb.version>1.11.139</aws-java-sdk-dynamodb.version>
    <rest-assured.verison>2.9.1-SNAPSHOT</rest-assured.verison>
    <json-path.version>2.9.0</json-path.version>
    <json.version>20160810</json.version>
    <xml-path.version>2.9.0</xml-path.version>
    <json-schema-validator.verison>2.9.0</json-schema-validator.verison>
    <poi.verison>3.15</poi.verison>
    <poi-ooxml.verison>3.15</poi-ooxml.verison>
    <poi-ooxml-schemas.version>3.15</poi-ooxml-schemas.version>
    <poi-scratchpad.version>3.2-FINAL</poi-scratchpad.version>
    <jackson-databind.version>2.8.5</jackson-databind.version>  
    <maven.compiler.plugin.version>3.6.1</maven.compiler.plugin.version>
    <opencsv>3.10</opencsv>
    <java.version>1.8</java.version>
    <!-- <maven.jar.plugin.version>3.0.2</maven.jar.plugin.version> -->
    <maven.jar.plugin.version>2.6</maven.jar.plugin.version>
    <maven-install-plugin.version>2.5.2</maven-install-plugin.version>

     <maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
     <!--<maven-surefire-plugin.version>2.12</maven-surefire-plugin.version> -->
    <skipTests>false</skipTests>
     <sometest>src/test/resources/testngxmls/sometest/test1.xml</sometest>
    <smoketest>src/test/resources/testngxmls/smoketest/test2.xml</smoketest>


</properties>


<build>
    <!-- <sourceDirectory>src</sourceDirectory> -->
    <plugins>

     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven.compiler.plugin.version}</version>
            <inherited>true</inherited>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>               

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>${maven.jar.plugin.version}</version>
            <inherited>true</inherited>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-install-plugin</artifactId>
            <version>${maven-install-plugin.version}</version>
            <executions>
                <execution>
                    <id>default-install</id>
                    <phase>install</phase>
                    <goals>
                        <goal>install</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
             <configuration>
                <skipTests>${skipTests}</skipTests>
                <suiteXmlFiles>
                    <xmlFile>${sometest}</xmlFile>
                    <xmlFile>${smoketest}</xmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

<dependencies>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>${testng.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${log4j.version}</version>
    </dependency>

    <dependency>
        <groupId>com.relevantcodes</groupId>
        <artifactId>extentreports</artifactId>
        <version>${relevantcodes.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>${poi.verison}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${poi-ooxml.verison}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml-schemas</artifactId>
        <version>${poi-ooxml-schemas.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-scratchpad</artifactId>
        <version>${poi-scratchpad.version}</version>
    </dependency>

    <!--adding only required jars of AWS -->

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-lambda-java-core</artifactId>
        <version>${aws-lambda-java-core.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-dynamodb</artifactId>
        <version>${aws-java-sdk-dynamodb.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>${rest-assured.verison}</version>
    </dependency>

    <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>json-path</artifactId>
        <version>${json-path.version}</version>
    </dependency>

    <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>xml-path</artifactId>
        <version>${xml-path.version}</version>
    </dependency>

    <dependency>
        <groupId>com.jayway.restassured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>${json-schema-validator.verison}</version>
        <!-- <scope>test</scope> -->
        <scope>compile</scope>
    </dependency>

    <dependency>
         <groupId>com.opencsv</groupId>
         <artifactId>opencsv</artifactId>
         <version>${opencsv}</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson-databind.version}</version>
    </dependency>

    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>${json.version}</version>
    </dependency>

    <dependency>

        <groupId>com.google.inject</groupId>
        <artifactId>guice</artifactId>
        <version>3.0</version>
    </dependency>

     <!-- <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-text</artifactId>
        <version>1.1</version>
    </dependency> -->
</dependencies>

<repositories>
    <repository>
        <id>sonatype</id>
        <url>http://ift.tt/1nniFTB;
        <snapshots />
    </repository>
</repositories>

With this pom.xml. I have been trying to use mvn command line to run selected suites independently, however it keeps executing all the suiteXmlFiles. The command I have used are as follows:

When I run this command $ mvn -e clean test -Dsurefire.xmlFile=sometest it runs sometest suite and then also runs all tests in smoketest. Similar observations with all the commands listed below.

$ mvn -e clean test -Dsurefire.xmlFiles=sometest

I have even tried changing the xmlFile to suiteXmlFile and file tags and running the respective commands:

$ mvn -e clean test -Dsurefire.suiteXmlFile=sometest $ mvn -e clean test -Dsurefire.suiteXmlFiles=sometest

$ mvn -e clean test -Dsurefire.suiteXmlFile=sometest $ mvn -e clean test -Dsurefire.suiteXmlFiles=sometest

Is there a way these tests can be run independently sticking to the suiteXmlFiles. This looks like a straightforward feature and it is puzzling why it would be so difficult to get this up and running.

Aucun commentaire:

Enregistrer un commentaire