[TestNG] No tests found. Nothing was run -- When tests are run from a testJar

11,684 views
Skip to first unread message

Musaffir lp

unread,
Jan 16, 2018, 12:23:57 AM1/16/18
to testng-users
Hello,

I have a maven project and I use testNg of version 6.13.1
[ The project is mainly to execute my selenium tests and I also have reportNg plugin configured in the pom.xml file not sure this plugin causing any prob here, hence mentioning here ]...

I am able to invoke mvn package command ...and it makes the test jar during its build cycle as expected fine ...I verified that the test jar contains the test class ...

I wanted to utilize this test jar for some of my other purposes and hence wanted to run from commandline by passing the path of suite xml file which is also present in the root path of jar......

I invoke from the coomandline as
java -cp MyTestJar.jar;lib/* org.testng.TestNG -testjar MyTestJar.jar -xmlpathinjar MyTestSuite.xml

lib/* - contains all the dependencies

but when this runs , the testNG is getting invoked, I could see it is considering correct suite xml file etc...but always giving me in return as below
[TestNG] No tests found. Nothing was run 


I could not figure out what is causing this .... I understand this message is purposefully added in testNG..
...
... TestNG 6.13.1 by Cédric Beust (ced...@beust.com)
...

===== Invoked methods
=====

===============================================
    My Test Name
    Tests run: 0, Failures: 0, Skips: 0
===============================================


===============================================
My Suite name
Total tests run: 0, Failures: 0, Skips: 0
===============================================

[TestNG] No tests found. Nothing was run
Usage: <main class> [options] The XML suite files to run
  Options:


Bit more info:
From the main maven project , I can use maven sure-fire plugin to execute the tests which is working fine .
In the maven build cycle it self I am making the test jar with below plugin
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

I make all dependencies to be stored in lib with
<plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-dependency-plugin</artifactId>
                            <version>3.0.2</version>
                            <executions>
                                <execution>
                                    <id>copy-dependencies</id>
                                    <phase>prepare-package</phase>
                                    <goals>
                                        <goal>copy-dependencies</goal>
                                    </goals>
                                    <configuration>
                                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
                                        <overWriteReleases>false</overWriteReleases>
                                        <overWriteSnapshots>false</overWriteSnapshots>
                                        <overWriteIfNewer>true</overWriteIfNewer>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>



Couldn't figure out it my own. Please let me know if you have any leads to the solution

Many Thanks
Musaffir

Mallikarjuna Rao

unread,
Jan 16, 2018, 5:48:19 AM1/16/18
to testng-users
Hi Musaffir , if there is any error in Listeners , you will end up such situation. Please check for any exceptions in Listener code.

Malli

Musaffir lp

unread,
Jan 17, 2018, 2:23:29 AM1/17/18
to testng-users
Thanks Malli for checking this
I have figured out it
The reportNG plugin was causing the issue here
It was configured  as
        <dependency>
           
<groupId>org.uncommons</groupId>
           
<artifactId>reportng</artifactId>
           
<version>1.1.2</version>
           
<scope>test<scope>  
           
<exclusions>
               
<exclusion>
                   
<groupId>org.testng</groupId>
                   
<artifactId>testng</artifactId>
               
</exclusion>
           
</exclusions>
       
</dependency>

Removing  <scope>test<scope> resolved the issue
I think its maven dependency issue when used testng seperately and used reportNg
I will update this forum with more explanation soon on this once i give some more study abt it ...hope it will be useful for future readers...

Thanks

himanshu mehta

unread,
Mar 21, 2020, 4:18:41 AM3/21/20
to testng-users
It shows errors while executing:

import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.http.Method;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;


public class TC01_GET_Request {
@Test
Void getweatherDetails(){
//BaseURL
RestAssured.baseURI="https://reqres.in/api/";
//Request Object
RequestSpecification httprequest=RestAssured.given();
//Response Object
Response response=httprequest.request(Method.GET,"users?page=2");
String responseBody=response.body().asString();
System.out.println(responseBody);

return null;



}


}

Error Log:

===============================================
Default suite
Total tests run: 0, Failures: 0, Skips: 0
===============================================

[TestNG] No tests found. Nothing was run
Usage: <main class> [options] The XML suite files to run
  Options:
    -configfailurepolicy
      Configuration failure policy (skip or continue)
    -d
      Output directory
    -dataproviderthreadcount
      Number of threads to use when running data providers
    -excludegroups
      Comma-separated list of group names to  exclude
    -groups
      Comma-separated list of group names to be run
    -junit
      JUnit mode
      Default: false
    -listener
      List of .class files or list of class names implementing ITestListener 
      or ISuiteListener
    -methods
      Comma separated of test methods
      Default: []
    -methodselectors
      List of .class files or list of class names implementing IMethodSelector
    -mixed
      Mixed mode - autodetect the type of current test and run it with 
      appropriate runner
      Default: false
    -objectfactory
      List of .class files or list of class names implementing 
      ITestRunnerFactory 
    -parallel
      Parallel mode (methods, tests or classes)
      Possible Values: [tests, methods, classes, instances, none, true, false]
    -port
      The port
    -reporter
      Extended configuration for custom report listener
    -suitename
      Default name of test suite, if not specified in suite definition file or 
      source code
    -suitethreadpoolsize
      Size of the thread pool to use to run suites
      Default: 1
    -testclass
      The list of test classes
    -testjar
      A jar file containing the tests
    -testname
      Default name of test, if not specified in suitedefinition file or source 
      code 
    -testnames
      The list of test names to run
    -testrunfactory, -testRunFactory
      The factory used to create tests
    -threadcount
      Number of threads to use when running tests in parallel
    -usedefaultlisteners
      Whether to use the default listeners
      Default: true
    -log, -verbose
      Level of verbosity
    -xmlpathinjar
      The full path to the xml file inside the jar file (only valid if 
      -testjar was specified)
      Default: testng.xml

Kindly please guide on urgent basis.

Thanks,
Himanshu

⇜Krishnan Mahadevan⇝

unread,
Mar 30, 2020, 12:23:51 AM3/30/20
to testng...@googlegroups.com
Its not clear what your issue is.

The error you are seeing usually happens when TestNG cannot find test classes to execute. The root cause can be anything.

So lets start from the basics in terms of context.

1. What version of TestNG are you using?
2. How does the project structure look like?
3. How are you executing your tests ?



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.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/8c512bd0-b8cc-4447-ba30-39c6dd95a505%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages