Creating instances of same object using different Factory class

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating instances of same object using different Factory class

pradeep pillai
hi all,

I am getting sporadic failures and not able to pin point the exact failures. My test user is getting logged out. It is not deterministic as failures are not consistent.

Please find stripped down version of code (options we have each type of user are huge and also the type of user is large.)

Class MyFactoryOne {
private Object[][] data;

@Factory(dataProvider="dp")
public Object[] createInstances(User user) {
return new Object[] { new TestFolderPermissionForUser(user)}; }
}

  @DataProvider(name="dp")
  public Object[][] dataProvider() {
  //
//create some user and login (login info stored in user object)
//
data = {{user1}, {user2}}
return data;
}

Class MyFactoryTwo {
private Object[][] data;

@Factory(dataProvider="dp")
public Object[] createInstances(User user) {
return new Object[] { new TestFolderPermissionForUser(user)}; }
}

  @DataProvider(name="dp")
  public Object[][] dataProvider() {
  //
//create some different type of user and login (login info stored in user object)
//
data = {{user1}, {user2}}
return data;
}

Class TestFolderPermissionForUser {
private User u;
TestFolderPermissionForUser(User u) {
this.u = u;
}

@Test
read() {

}

@Test (dependsOnMethod = "read")
rename() {

}

@Test (dependsOnMethod = "read")
delete() {

}
}


<suite parallel="tests" thread-count="5">
    
    <test name="Test for free user" group-by-instances="true">
        <classes>
            <class name="com.test.MyFactoryOne"/>
        </classes>
    </test>
    <test name="Test for paid user" group-by-instances="true">
        <classes>
            <class name="com.test.MyFactoryTwo"/>
        </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.
Reply | Threaded
Open this post in threaded view
|

Re: Creating instances of same object using different Factory class

⇜Krishnan Mahadevan⇝

Can you please let us know what issue you are facing with respect to TestNG ?

Can you share a standalone sample, that can be executed to reproduce the issue you are facing ?

 

Thanks & Regards

Krishnan Mahadevan

 

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

 

From: <[hidden email]> on behalf of pradeep pillai <[hidden email]>
Reply-To: <[hidden email]>
Date: Friday, December 8, 2017 at 2:24 PM
To: testng-users <[hidden email]>
Subject: [testng-users] Creating instances of same object using different Factory class

 

hi all,

 

I am getting sporadic failures and not able to pin point the exact failures. My test user is getting logged out. It is not deterministic as failures are not consistent.

 

Please find stripped down version of code (options we have each type of user are huge and also the type of user is large.)

 

Class MyFactoryOne {

               

                private Object[][] data;

 

                @Factory(dataProvider="dp")

                public Object[] createInstances(User user) {

                                return new Object[] { new TestFolderPermissionForUser(user)}; }

                }

 

  @DataProvider(name="dp")

  public Object[][] dataProvider() {

                //

                //create some user and login (login info stored in user object)

                //

                data = {{user1}, {user2}}

                return data;

}

 

Class MyFactoryTwo {

               

                private Object[][] data;

 

                @Factory(dataProvider="dp")

                public Object[] createInstances(User user) {

                                return new Object[] { new TestFolderPermissionForUser(user)}; }

                }

 

  @DataProvider(name="dp")

  public Object[][] dataProvider() {

                //

                //create some different type of user and login (login info stored in user object)

                //

                data = {{user1}, {user2}}

                return data;

}

 

Class TestFolderPermissionForUser {

                private User u;

                TestFolderPermissionForUser(User u) {

                                this.u = u;

                }

 

                @Test

                read() {

 

                }

 

                @Test (dependsOnMethod = "read")

                rename() {

 

                }

 

                @Test (dependsOnMethod = "read")

                delete() {

 

                }

}

 

 

<suite parallel="tests" thread-count="5">

    

    <test name="Test for free user" group-by-instances="true">

        <classes>

            <class name="com.test.MyFactoryOne"/>

        </classes>

    </test>

    <test name="Test for paid user" group-by-instances="true">

        <classes>

            <class name="com.test.MyFactoryTwo"/>

        </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.

--
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.