beforeclass(instance1)
beforeclass(instance2)
beforeclass(instance3)
test(instance1)
test(instance2)
test(instance3)
afterclass(instance1)
afterclass(instance2)
afterclass(instance3)
Beforeclass starts a browser and logs into a user account and afterclass
logs out and closes the browser,
so this is a huge problem, since it means that there will be 3 browsers
opened at the same time logged in with the same user.
My goal is to have the instances run one after another:
beforeclass(instance1)
test(instance1)
afterclass(instance1)
beforeclass(instance2)
test(instance2)
afterclass(instance2)
beforeclass(instance3)
test(instance3)
afterclass(instance3)
is there any way to achieve that ?
It doesn't matter in which order the instances (or even the tests) are
executed, just that they are separate
Thanks in advance
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31495933.html
Sent from the testng-users mailing list archive at Nabble.com.
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31498075.html
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31503266.html
Santo
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31506381.html
Santo Pfingsten wrote:
>
> I wonder.. how did you get the @Factory to work inside your test class ?
> I had to create a separate class for the factory, otherwise it wouldn't
> work.
>
> I'm using NetBeans too and don't have MultiThreading (altho I thought it
> might be multithreaded when the problem described in the topic was
> happening, but it was just tests running mixed together).
>
> As for the ordering, I use a custom annotation @Priority in combination
> with an IMethodInterceptor.
> (sorting the methods by browser, class name and then priority)
> dependsOn* and priority of the @Test would not be instance-safe.
>
> Thanks for the detailed input, it was very interesting.
> I'm doing it kinda similar.
> I have a base class, which does all the selenium specific stuff like
> starting a browser, write screenshots/failure dumps, loading various
> .properties files for configuring the tests, etc.
> Then I have an Assert class which inherits from the base class and adds
> all the assert/verify/fail methods for convenience.
> Then I have a TestNG class, which simply adds an @afterclass to close the
> browser.
> That's the one every test inherits from.
> And then for every test I create an @factory class to start one instance
> for each browser (browsers loaded from a common properties file).
> If I could skip the factory class it would really be great, but all I
> found on google was that you'd have to create your own class for the
> @factory.
>> methods SEQUENTIALLY using the *@Test(singleThreaded = true)* annotation
>> on
>> the CLASS. This is a MUST for testing with selenium, unless you start
>> creating/managing multiple selenium instances. However, this 1:1
>> relationship at the class level is very natural and works well so far.
>>
>> When test methods were autonomous, this is all that was needed since the
>> execution order didn't matter. However, I tend to like smaller, more
>> granular test methods that perform individual steps in a multi-step
>> process
>> and thus want run tests in a guaranteed order for a given browser
>> session.
>> To do this, I used the *@Test(dependsOnMethods = { ... } )* on each
>> method
>> in the sequence. However, this is very brittle and hard to manage
>> *(Hint:
>> I'm open for suggestions on a more maintainable method to guarantee
>> ordering
>> of test methods within a test class as opposed to hard coding the
>> dependency
>> relationship or relying on the .XML testsuite file).*
>>
>> Here is my factory method. I'm happy to share more detail if
>> needed...just
>> ping me. I have a 'dev' mode that creates only one test class instance
>> for
>> dev/debugging purposes and defaults to FIREFOX36. Otherwise, it takes a
>> comma-separated list of browsers and will create a test class instance
>> for
>> each browser specified (same or different browsers) and an associated
>> selenium instance. So far it works well but there are improvements I
>> need
>> to make to it still:
>>
>> @Factory
>> public Object[] testFactory() {
>> ArrayList tests = new ArrayList();
>> I ♥ DropBox <http://db.tt/9O6LfBX> !!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "testng-users" group.
>> To post to this group, send email to testng...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> testng-users...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/testng-users?hl=en.
>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31523767.html
> methods SEQUENTIALLY using the *@Test(singleThreaded = true)* annotation
> on
> the CLASS. This is a MUST for testing with selenium, unless you start
> creating/managing multiple selenium instances. However, this 1:1
> relationship at the class level is very natural and works well so far.
>
> When test methods were autonomous, this is all that was needed since the
> execution order didn't matter. However, I tend to like smaller, more
> granular test methods that perform individual steps in a multi-step
> process
> and thus want run tests in a guaranteed order for a given browser session.
> To do this, I used the *@Test(dependsOnMethods = { ... } )* on each method
> in the sequence. However, this is very brittle and hard to manage *(Hint:
> I'm open for suggestions on a more maintainable method to guarantee
> ordering
> of test methods within a test class as opposed to hard coding the
> dependency
> relationship or relying on the .XML testsuite file).*
>
> Here is my factory method. I'm happy to share more detail if
> needed...just
> ping me. I have a 'dev' mode that creates only one test class instance
> for
> dev/debugging purposes and defaults to FIREFOX36. Otherwise, it takes a
> comma-separated list of browsers and will create a test class instance for
> each browser specified (same or different browsers) and an associated
> selenium instance. So far it works well but there are improvements I need
> to make to it still:
>
> @Factory
> public Object[] testFactory() {
> ArrayList tests = new ArrayList();
> I ♥ DropBox <http://db.tt/9O6LfBX> !!
>
> --
> You received this message because you are subscribed to the Google Groups
> "testng-users" group.
> To post to this group, send email to testng...@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>
>
>
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31522900.html
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31522795.html
browser=[FIREFOX36|IE8|CHROME|HtmlUnit]devMode=[true|false]
browser=FIREFOX36,FIREFOX36,FIREFOX36,FIREFOX36 //4 instances in parallel.devMode=false
browser=FIREFOX36,IE8,CHROMEdevMode=false
Nevermind the factory inside a class, I just found that it is a good idea to
keep it in a separate class so you can start the test with just one browser
instead of all.
> it.<http://groups.google.com/group/testng-users/browse_thread/thread/9c21b07009904aef>
>
> --
> 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...@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>
>
>
--
View this message in context: http://old.nabble.com/%40Factory-execution-order-tp31495933p31530392.html