I have test ready but I can't run test because I am working in normal java but for running multiple test I am using TestNG but I don't know how to run multiple test using TestNG code and also I don't know how to map it with listener class.
I have tried below code :
TestNG test = new TestNG() ;
test.setTestClasses(new Class[] {class name.class}) ;
test.run() ;
But I don't now for multiple test and for parallel test how to proceed further and also I don't know how to map listeners class to it. Please help me to deal with this
XML file is much more convenient and much easier to read/handle/reuse/etc.
If you are really sure you want to run the test programmatically, then I suggest you read the official documentation about how to do it.
It all depends on your exact needs. From the question, the approximate code to run multiple tests (assuming test classes) with listeners may look like the following:
The official documentation contains an example with Suite and Test objects, in case you want to have them.