How to set TestNG in classpath in Maven project?

3,200 views
Skip to first unread message

Gajanan Mahajan

unread,
Mar 28, 2015, 11:52:42 AM3/28/15
to testng...@googlegroups.com

In order to run TestNG tests on command line, I'll have to set TestNG in classpath. To do so, I went through -

Unable to execute TestNG Suite file via command line

Getting error Could not find or load main class org.testng.TestNG

which tells that if testng.jar is in lib folder of the project, then do set path until lib folder(like - C:\Workspace\projectname\lib\*) in classpath.

But in my case, I'm using Maven project and hence don't have lib folder to put jars. In this case, how can I set TestNG in classpath? And hence run TestNG tests on command line.

Nick Stolwijk

unread,
Mar 28, 2015, 12:04:39 PM3/28/15
to testng...@googlegroups.com
You can add the TestNG artifact[1] as testdependency and then run "mvn test" to execute your tests. The M-Surefire-Plugin understands TestNG.[2]


Hth,

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when your turn comes to die, you can die happy in feeling that at any rate you have not wasted your time but have done your best ~~~

Lord Baden-Powell

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

Varun Menon

unread,
Mar 28, 2015, 2:21:14 PM3/28/15
to testng...@googlegroups.com

Hi,

You can use maven itself to execute your tests. You need to do following things to use maven:
- Add Testng as dependent jar with scope as "test".
- Use surefire plugin.
- Your test classes should be placed under src/test/java folder or configure your pom.xml to set test source directory.

-Varun

--

pdfngreport

unread,
Apr 1, 2015, 3:03:05 PM4/1/15
to testng...@googlegroups.com, gajanan...@gmail.com
Hi,

i have sample of testng with ant/maven and pdf report. it may help check this git  https://github.com/uttesh/pdfngreportdemo,

SHARDHA SHARMA

unread,
Sep 6, 2019, 2:21:19 PM9/6/19
to testng-users
Hi All,

I am unable to run listener testng suite file. please help.

[RemoteTestNG] detected TestNG version 6.14.2
org.testng.TestNGException: 
Listener listener.TestNGListener was not found in project's classpath
at org.testng.TestNG.addListeners(TestNG.java:946)
at org.testng.TestNG.initializeConfiguration(TestNG.java:912)
at org.testng.TestNG.initializeEverything(TestNG.java:996)
at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

⇜Krishnan Mahadevan⇝

unread,
Sep 9, 2019, 12:39:57 AM9/9/19
to testng...@googlegroups.com
Without any contextual information in terms of what you are doing to trigger this error, there's hardly anyone can do to help you out.
So please help share a sample project which we can use to reproduce the error.

The error clearly says that testNG is not able to find your listener class. Please double check your class's fully qualified class name.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages