@Factory method of all tests gets executed at start of the suite

View: New views
3 Messages — Rating Filter:   Alert me  

@Factory method of all tests gets executed at start of the suite

by Harihara Vinayakaram :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
   The @Factory method of all tests in the test suite get executed in the beginning of the run.  (i.e.) with the following testng.xml

<suite>
     <test name = "test1">
            <classes>
                 <class name="Test1"/>
            </classes>
      </test>

      <test name="test2">
             <classes>
                <class name="Test2" />
              </classes>
      </test>
</suite>

running via the ant TestNG task

executes the @Factory method of Test1, @Factory method of Test2  and then executes the test1, test2

The problem I have is that I want the @Factory method to read a file produced as an output of running class Test1 . Is there a way I can change this behavior .  I tried using @DataProvider but @Factory is much cleaner for my tests

Can I change the behavior .

Regards
Hari

I am using testng 5.10 and my tests are in groovy



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: @Factory method of all tests gets executed at start of the suite

by Harihara Vinayakaram :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry for asking a  RTFM question :-) . . I have annotated these tests alone with a @DataProvider method

Sorry for the trouble

Regards
Hari

On Fri, Oct 23, 2009 at 1:07 PM, Harihara Vinayakaram <hvram1@...> wrote:
Hi
   The @Factory method of all tests in the test suite get executed in the beginning of the run.  (i.e.) with the following testng.xml

<suite>
     <test name = "test1">
            <classes>
                 <class name="Test1"/>
            </classes>
      </test>

      <test name="test2">
             <classes>
                <class name="Test2" />
              </classes>
      </test>
</suite>

running via the ant TestNG task

executes the @Factory method of Test1, @Factory method of Test2  and then executes the test1, test2

The problem I have is that I want the @Factory method to read a file produced as an output of running class Test1 . Is there a way I can change this behavior .  I tried using @DataProvider but @Factory is much cleaner for my tests

Can I change the behavior .

Regards
Hari

I am using testng 5.10 and my tests are in groovy




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: @Factory method of all tests gets executed at start of the suite

by Cédric Beust ♔ :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Harihara,

No, it's not possible.  TestNG needs to run all the factories before the tests since it can't know what these tests are until all the factories have run.

Can't you extract the code that produces this file from your tests and make sure that it's run in an @AfterSuite first?

--
Cedric


On Fri, Oct 23, 2009 at 7:48 AM, Harihara Vinayakaram <hvram1@...> wrote:
Sorry for asking a  RTFM question :-) . . I have annotated these tests alone with a @DataProvider method

Sorry for the trouble

Regards
Hari


On Fri, Oct 23, 2009 at 1:07 PM, Harihara Vinayakaram <hvram1@...> wrote:
Hi
   The @Factory method of all tests in the test suite get executed in the beginning of the run.  (i.e.) with the following testng.xml

<suite>
     <test name = "test1">
            <classes>
                 <class name="Test1"/>
            </classes>
      </test>

      <test name="test2">
             <classes>
                <class name="Test2" />
              </classes>
      </test>
</suite>

running via the ant TestNG task

executes the @Factory method of Test1, @Factory method of Test2  and then executes the test1, test2

The problem I have is that I want the @Factory method to read a file produced as an output of running class Test1 . Is there a way I can change this behavior .  I tried using @DataProvider but @Factory is much cleaner for my tests

Can I change the behavior .

Regards
Hari

I am using testng 5.10 and my tests are in groovy








--
Cédric



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users@...
To unsubscribe from this group, send email to testng-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en
-~----------~----~----~----~------~----~------~--~---