mercredi 16 novembre 2016

Unable to execute Test Methods in Parallel in TestNG

I am creating a Testing framework using selenium ,TestNG & Maven. As a part of it i am trying to implement Parallel test execution.

I Created 2 Test methods (using @tests) in a single Test case file. When i am trying use TestNG Parallel Methods with Thread count 2, its not working as expected. 2 Browsers are invoking , but both tests executing in a single browser parallely

 <?xml version="1.0" encoding="UTF-8"?>
 <suite name="Login-suite" parallel="methods" thread-count="2">
 <test name="Login-Test" group-by-instances="true">
    <classes>
        <class name="org.framework.automation.Testcases.LoginTest" />
    </classes>
</test>
</suite>

Instead when i am trying to create two TestNG classes for 2 tests and creating 2 Tests in TestNG.xml one for each test class i am able to execute it parallely.

 <?xml version="1.0" encoding="UTF-8"?>
 <suite name="Login-suite" parallel="tests" thread-count="2">
<test name="Login-Test" group-by-instances="true">
    <classes>
        <class name="org.framework.automation.Testcases.LoginTest" />
    </classes>
</test>
<test name="Login-Test2" group-by-instances="true">
    <classes>
        <class name="org.framework.automation.Testcases.InvalidLoginTest" />
    </classes>
</test>
</suite>

Below is the link for my framework Bitbucket Link for Code

Need your inputs on this. Can you also suggest

what is the best approach for parallel execution . Can i maintain multiple Tests (@tests) in multiple Test classes ?

Is it good to maintain all Tests (@tests)relating to corresponding scenario (Say all login scenarios , Checkout scenarios , My account scenarios) in a single file and executing each tests in parallel?

Final - May be dumb question - Parallel execution means executing multiple Test(@tests) in parallel or executing multiple Test case files -Which one is good option ?

Thank you.

Aucun commentaire:

Enregistrer un commentaire