Quantcast

Re: When group-by-instances is set to true the instances created by @Factory does not run in parallel

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: When group-by-instances is set to true the instances created by @Factory does not run in parallel

Brandon Dudek
It is a known bug: https://github.com/cbeust/testng/issues/326

Please comment on it in GitHub, to get some attention.

On Monday, August 15, 2016 at 5:39:09 PM UTC-4, Rohit Gupta wrote:
Hi All,

I am facing a problem when trying to run test cases in parallel with below setup.
On removing group-by-instances="true" from testng xml starts test execution in parallel. But problem with that approach is dependent test will only initiate when all parent tests are completed which i dont want.

Can somebody please help if somebody able to resolve this issue?



package test;

import org.apache.log4j.Logger;
import org.testng.annotations.*;
import org.testng.annotations.Test;

public class TestTest
{
    private String param;

    @Factory( dataProvider = "prov" )
    public TestTest( String param )
    {
        this.param = param;
    }

    @DataProvider( name = "prov" )
    public static Object[][] dataProvider()
    {
        System.out.println( "[" + Thread.currentThread().getId() +  "] Provide data" );
        return new Object[][] {
                { "One" },
                { "Two" },
                { "Three" },
        };
    }

    @BeforeClass
    public void prepare()
    {
        System.out.println( "[" + Thread.currentThread().getId() +  "] Prepare " + param );
    }

    @Test
    public void test1()
    {
        System.out.println( "[" + Thread.currentThread().getId() +  "] Test1 " + param );
    }

    @Test( dependsOnMethods = "test1" )
    public void test2()
    {
        System.out.println( "[" + Thread.currentThread().getId() +  "] Test2 " + param );
        sleep();
    }

    @AfterClass
    public void clean()
    {
        System.out.println( "[" + Thread.currentThread().getId() +  "] Clean " + param );
    }

    private void sleep() {
        try {
            Thread.sleep(10000);
        } catch (Exception ignored) {}
    }
}

With the following testng.xml:

<!DOCTYPE suite SYSTEM "<a href="http://testng.org/testng-1.0.dtd" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ftestng.org%2Ftestng-1.0.dtd\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFHihXzQ1YlwcxcDehnw97TuniFLA&#39;;return true;">http://testng.org/testng-1.0.dtd" >

<suite name="Suite" parallel="instances" thread-count="5" group-by-instances="true">
  <test name="Tests">
    <classes>
       <class name="test.TestTest" />
    </classes>
  </test>
</suite>

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Loading...