Run a TestNG project with Maven

Hola Testors!

Today I’m gonna show you how to run TestNG project with Maven. I’m taking my previous TestNG project for this one. You can download it from here.

I tried to run it in maven. Build got success. But you won’t see run anything.

Screen Shot 2015-09-20 at 2.54.58 PM

There is a solution for this: surefire plugin 😀

You need to add testng dependency to pom.xml and add below plugin too.


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
                <suiteXmlFiles>
                    <suiteXmlFile>crossbrowsing.xml</suiteXmlFile>
                </suiteXmlFiles>
            </configuration>
        </plugin>
    </plugins>
</build>

Here suiteXmlFile is out testng xml. You can pass many parameters with this plugin according to your scenarios. For more info about maven testng surefire plugin visit maven page.

See you soon!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s