Software Technology - Development and Test Engineering, software testing

Maven + Surefire + Testng

If you are planning to write tests using Maven, Surfire and Testng then you may proceed  to the next lines.

1. Add dependency to your pom.xml


2. Write your test

public void myTest(){

3. Run Test
how to run a single test from command-line ?

mvn clean -Dtest=<your test> test -Dvar1=<value>

  • clean is to make sure your tests are recompiled
  • <your test> should be the complete path to the class e.g.
  • -Dvar1 system variables that/those you might want to pass to your tests e.g. -VtestUrl=

how to debug ?

mvn -Dmaven.surefire.debug test

debugging a single tests

mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" test

How to run a testng from Eclipse IDE with arguments to the tests ?

  • Goto IDE and testng run configuration
  • Write in VM arguments
    •  -D<variable_name>=<variable value>

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s