Hi Ashish,
I am getting below error when running runner class. Please help
[TestNG] [ERROR] No test suite found. Nothing to run
Usage: <main class> [options] The XML suite files to run
Options:
-alwaysrunlisteners
Should MethodInvocation Listeners be run even for skipped methods
Default: true
-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
-threadpoolfactoryclass
The threadpool executor factory implementation that TestNG should use.
-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
Instructor
Ashish Thakur Replied on 09/06/2021
No test suite found. Nothing to run
Usage: <main class> [options] The XML suite files to run
this means you have not mentioned the suites to be executed..
May be file path is incorrect or some config is not correct
Hi Ashish,
I have provided the suite name in the path. Below is the code:
public static void main(String[] args) {
// TODO Auto-generated method stub
TestNgRunner testNg = new TestNgRunner(1);
//we will create constructor for TestNgRunner which takes int value. It defines the number of test suites run parallely
testNg.createSuiteName("Portfolio_Suite", false);
testNg.addListner("listener.CustomListner");
testNg.addTest("Add_new_stock");
testNg.addTestParam("action", "addstock");
List<String> includedMethods = new ArrayList<String>();
testNg.addTestClass("testRediff.PortFolioManagement", includedMethods);
includedMethods = new ArrayList<String>();
includedMethods.add("selectPortfolio");
testNg.addTestClass("testRediff.StockManagement", includedMethods);
includedMethods.add("AddStock");
includedMethods.add("VerifyStockInList");
testNg.run();
}
Instructor
Ashish Thakur Replied on 11/06/2021
You have to add the test suite in TestNG
Have you done that in TestNgRunner
Hi Ashish,
Yes I have added in TestNgRunner as well:
public class TestNgRunner {
TestNG testng;
XmlSuite suite; //single suite
List<XmlSuite> allsuites; //list of all suites
XmlTest test; //single test case
List<XmlTest> allTestCase; //list of all test cases under a test suite
Map<String,String> testParam;
List<XmlClass> classes;// all the classes inside the test.
public TestNgRunner(int suiteThreadPool) { //constructor for TestNgRunner
allsuites = new ArrayList<XmlSuite>();//All suites and initialized the list. it is empty list
testng = new TestNG();//initialize testng
testng.setSuiteThreadPoolSize(suiteThreadPool);//How many parallel suites will run
testng.setXmlSuites(allsuites);
}
public void createSuiteName(String suiteName, boolean parallelTest) {
// create suite Name.
//boolean : it will help to run the test in parallel. If true test will parallel if not will not run.
suite = new XmlSuite();
suite.setName(suiteName);
if(parallelTest) {
suite.setParallel(ParallelMode.TESTS);//(To run the suite parallely)
allsuites.add(suite);//Add suite in allsuites
}
}
Instructor
Ashish Thakur Replied on 15/06/2021
Please zip and send me your project
Hi Ashish,
I have attached the project.
Please have a look.
Thanks,
Gautam Prakash
Hi Ashish,
Hope you are doing well.
Any update.
Thanks,
Gautam