jeudi 3 novembre 2016

How to quit the testNg class after getting the result

I had posted a question http://ift.tt/2fh8gcO regarding "How to run a test class from another java class" and the problem got resolved after implementing the code.

    @Listeners(value = {PreconditionListener.class})
    public class ListenerMain  {
    private static String serviceTypeUseParameter ;
    private static Logger logger = LogManager.getLogger(ListenerMain .class.getName());
    @BeforeClass
    //TestNg Annotation
    public void setup()
    {
         if (serviceTypeUseParameter.equals("ListenerTest1Method")){
             logger.info("########## Entered ListenerTest1Method class ########");
             tla = new TestListenerAdapter();
             testng = new TestNG();
             testng.setTestClasses(new Class[] { com.company.test.ListenerTest1Method.class });
             testng.addListener(tla);
             testng.run();
             logger.info("########## End SBE_users_interactions class ########");
         }
              else{
         // Run ListenerTest2 class
        }
    }
}

But my After the getting the output hudson job is still running (stuck).I didn't find this issue when i'm running my class individually. OUTPUT :-

===============================================
Command line suite
Total tests run: 16, Failures: 0, Skips: 0
===============================================

06:55:41.781 [main] INFO  com.company.test.ListenerTest1Method - ########## ListenerTest1Method class ########

How to stop it? Is this because my code is main method of java?

Aucun commentaire:

Enregistrer un commentaire