Cirko
Cirko

Reputation: 47

Can pom.xml be set up to run testNG(UI perf. tests) tests and jUnit(unit tests) tests separately, from command line?

The process requires tests to be performed on a branch before a pull request can be approved. Since testNG is used for UI Selenium tests and jUnit for unit tests, pom.xml plugins had to be set like this:

<plugins>
        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${surefire.version}</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-junit47</artifactId>
                    <version>${surefire.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.maven.surefire</groupId>
                    <artifactId>surefire-testng</artifactId>
                    <version>${surefire.version}</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>

UI tests are run with test xml suite which has to be defined somewhere in pom.xml(not sure where to put that line). Can pom.xml be set up so tests can be done separately? e.g. mvn -DsuiteXmlFile=/path/to/file and `mvn -Dtest=package.with.unit.tests'

Upvotes: 2

Views: 36

Answers (1)

Sameer Arora
Sameer Arora

Reputation: 4507

Yes you can do that. You need to make two separate testng files with different names and add unit tests in one testng and performance tests in other and you can parameterised it from the pom.xml like:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20.1</version>
    <configuration>
        <suiteXmlFiles>
            <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
        </suiteXmlFiles>
    </configuration>
</plugin>

Upvotes: 1

Related Questions