Initialisation method(s) before all suites

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

Initialisation method(s) before all suites

Arno Jost
Hi there

I've browsed quite a lot of posts before posting my own without finding the answer to my subject. But i'm sure some of you must have faced the same situation, so please apologize if i just missed the right one.

We're implementing a software in distributed teams (let's call them A, B, C,...) where different topics (1, 2, 3, ...) are covered by developer. We now want to cover all the implementation with testng with the ability to:
a) run all the tests from a central place
b) run only a few tests concerning one topic in one team (e.g. B2)

We've thought about a suite-tree looking like following

  suite_root
  |          
  suite_A                     suite_B              ...
  |           |                 |           |
  suite_A1 suite_A2 ...   suite_B1 suite_B2 ...

where the dependencies are created by <suite-files>-tags, so e.g.
  <suite name="suite_A">
    <suite-files>
      <suite-file path="./suite_A1.xml"/>
      <suite-file path="./suite_A2.xml"/>
    </suite-files>
  </suite>

So far so good, now comes the nut to crack:
The first step of some testing activity MUST allways be some method(s) that does some one-time initialisation (setting up the persistence layer...)

The intuitive approach of calling also a class in the root-suite with a method annotated with @BeforeSuite won't do the job, as:
a) the order of execution of the methods/suites will be from bottom to top (root-suite called finaly)
b) we can't force that the root-suite is always executed as the developer must be able to call only the suite_B2 or ideally (if possible) even some individual test-classes (still with initialization!)

I've looked at the concepts of (partial) groups and hard/soft dependencies but i don't see a clean solution neither with these neither.

Thanx in advance for any hint or link to a post that allready discusses the topic or for a proposed solution!

Greets,
Arno

p.s. please apologise any ugly wording or spelling mistakes, english is only my third language... ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Initialisation method(s) before all suites

Nalin Makar
why wont @BeforeSuite work? 

a. First of all, I think the order of execution is top-down. The root suite is going to be executed first and then the suites that it includes and so on.

b. Also, you can have all these tests extend a common base class which contains a method annotated @BeforeSuite. This method can check to see if the one-time initialization is already done or not. If it's not done, it does it there, otherwise it simply returns.

Does this help?

-nalin



On Thu, Apr 28, 2011 at 12:09 AM, Jostar <[hidden email]> wrote:

Hi there

I've browsed quite a lot of posts before posting my own without finding the
answer to my subject. But i'm sure some of you must have faced the same
situation, so please apologize if i just missed the right one.

We're implementing a software in distributed teams (let's call them A, B,
C,...) where different topics (1, 2, 3, ...) are covered by developer. We
now want to cover all the implementation with testng with the ability to:
a) run all the tests from a central place
b) run only a few tests concerning one topic in one team (e.g. B2)

We've thought about a suite-tree looking like following

 suite_root
 |
 suite_A                     suite_B              ...
 |           |                 |           |
 suite_A1 suite_A2 ...   suite_B1 suite_B2 ...

where the dependencies are created by <suite-files>-tags, so e.g.
 <suite name="suite_A">
   <suite-files>
     <suite-file path="./suite_A1.xml"/>
     <suite-file path="./suite_A2.xml"/>
   </suite-files>
 </suite>

So far so good, now comes the nut to crack:
The first step of some testing activity MUST allways be some method(s) that
does some one-time initialisation (setting up the persistence layer...)

The intuitive approach of calling also a class in the root-suite with a
method annotated with @BeforeSuite won't do the job, as:
a) the order of execution of the methods/suites will be from bottom to top
(root-suite called finaly)
b) we can't force that the root-suite is always executed as the developer
must be able to call only the suite_B2 or ideally (if possible) even some
individual test-classes (still with initialization!)

I've looked at the concepts of (partial) groups and hard/soft dependencies
but i don't see a clean solution neither with these neither.

Thanx in advance for any hint or link to a post that allready discusses the
topic or for a proposed solution!

Greets,
Arno

p.s. please apologise any ugly wording or spelling mistakes, english is only
my third language... ;-)
--
View this message in context: http://old.nabble.com/Initialisation-method%28s%29-before-all-suites-tp31493959p31493959.html
Sent from the testng-users mailing list archive at Nabble.com.

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


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Initialisation method(s) before all suites

Arno Jost
a. i'm more than sure (cause i tested it) that suites are executed bottom-top.
See also this post about a discussion going into that:
http://old.nabble.com/Controlling-order-between-suite-files-td8863629.html#a8863629

b. thought about a solution of that type (having the initialisation in the first TestCase actually runing) but the combination with @BeforeSuite is better because the exeucution time of the first TestCase will then be "clean". Anyway, i'll have to do it with a static class to be able to remember that the initialisation was allready done when i enter the second TestCase and to tell you the truth i don't feel confortable about using some static classes there. Not to mention the problems i may encounter when starting to run the tests in parallel... :-/


Nalin Makar wrote
why wont @BeforeSuite work?

a. First of all, I think the order of execution is top-down. The root suite
is going to be executed first and then the suites that it includes and so
on.

b. Also, you can have all these tests extend a common base class which
contains a method annotated @BeforeSuite. This method can check to see if
the one-time initialization is already done or not. If it's not done, it
does it there, otherwise it simply returns.

Does this help?

-nalin



On Thu, Apr 28, 2011 at 12:09 AM, Jostar <arno.jost@hispeed.ch> wrote:

>
> Hi there
>
> I've browsed quite a lot of posts before posting my own without finding the
> answer to my subject. But i'm sure some of you must have faced the same
> situation, so please apologize if i just missed the right one.
>
> We're implementing a software in distributed teams (let's call them A, B,
> C,...) where different topics (1, 2, 3, ...) are covered by developer. We
> now want to cover all the implementation with testng with the ability to:
> a) run all the tests from a central place
> b) run only a few tests concerning one topic in one team (e.g. B2)
>
> We've thought about a suite-tree looking like following
>
>  suite_root
>  |
>  suite_A                     suite_B              ...
>  |           |                 |           |
>  suite_A1 suite_A2 ...   suite_B1 suite_B2 ...
>
> where the dependencies are created by <suite-files>-tags, so e.g.
>  <suite name="suite_A">
>    <suite-files>
>      <suite-file path="./suite_A1.xml"/>
>      <suite-file path="./suite_A2.xml"/>
>    </suite-files>
>  </suite>
>
> So far so good, now comes the nut to crack:
> The first step of some testing activity MUST allways be some method(s) that
> does some one-time initialisation (setting up the persistence layer...)
>
> The intuitive approach of calling also a class in the root-suite with a
> method annotated with @BeforeSuite won't do the job, as:
> a) the order of execution of the methods/suites will be from bottom to top
> (root-suite called finaly)
> b) we can't force that the root-suite is always executed as the developer
> must be able to call only the suite_B2 or ideally (if possible) even some
> individual test-classes (still with initialization!)
>
> I've looked at the concepts of (partial) groups and hard/soft dependencies
> but i don't see a clean solution neither with these neither.
>
> Thanx in advance for any hint or link to a post that allready discusses the
> topic or for a proposed solution!
>
> Greets,
> Arno
>
> p.s. please apologise any ugly wording or spelling mistakes, english is
> only
> my third language... ;-)
> --
> View this message in context:
> http://old.nabble.com/Initialisation-method%28s%29-before-all-suites-tp31493959p31493959.html
> Sent from the testng-users mailing list archive at Nabble.com.
>
> --
> 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@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>
>

--
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@googlegroups.com.
To unsubscribe from this group, send email to testng-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.