@BeforeClass behaviour

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

@BeforeClass behaviour

Mimil Mimil

Hi,

I want to come back to a behaviour I misreported as bug in JIRA
(TESTNG-136) about @BeforeClass. As for me there is difference to run a
test by a classname or making a selection by group name you assigned to
them. I mean If a @BeforeClass is expected in a test class then any
test in it must use it whatever the maner the tests get called.

Before misreporting it as bug I did a fast look on the documentation
about TestNG groups but I didn't see any topics about that. Alexandru
told me that I must add the attribut alwaysRun="true" to have the
expected behaviour and to check back the documentation and I found the
information in the Annotations section. (Perhaps a little reminder in
Groups section could be idea to avoid ppl like me asking)

So can you give the use case that may cause troubles and has motivated
the TestNG developers to choose to set alwaysRun="false" as default
instead of ="true"? As I am not a yet a test framework specialist, can
you show me the path to enlightment?

Thanks and sorry to have reported it as bug at first instead of asking
to the ML.

Regards,
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 [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: @BeforeClass behaviour

Alexandru Popescu ☀

On 1/15/07, [hidden email] <[hidden email]> wrote:

>
> Hi,
>
> I want to come back to a behaviour I misreported as bug in JIRA
> (TESTNG-136) about @BeforeClass. As for me there is difference to run a
> test by a classname or making a selection by group name you assigned to
> them. I mean If a @BeforeClass is expected in a test class then any
> test in it must use it whatever the maner the tests get called.
>
> Before misreporting it as bug I did a fast look on the documentation
> about TestNG groups but I didn't see any topics about that. Alexandru
> told me that I must add the attribut alwaysRun="true" to have the
> expected behaviour and to check back the documentation and I found the
> information in the Annotations section. (Perhaps a little reminder in
> Groups section could be idea to avoid ppl like me asking)
>
> So can you give the use case that may cause troubles and has motivated
> the TestNG developers to choose to set alwaysRun="false" as default
> instead of ="true"? As I am not a yet a test framework specialist, can
> you show me the path to enlightment?
>
> Thanks and sorry to have reported it as bug at first instead of asking
> to the ML.
>
> Regards,
> Cédric,
>

I will give a short example that will hopefully explain the reasons:

Say I have a test class for a DAO: a couple of test are mock tests -
do not require access to the DB, and a couple of other tests should be
run against some real table with custom data in.

To do this I will create my test class with 2 @BeforeClass methods:
one that is setting up my mocking environment and one that is setting
up my real DB connection and data. However I don't want to always run
both "sets" of test as my DB will not be up all time. Due to this I
group my test methods in 2 groups: "mocks", "db", so that when I know
my DB is not up I just run the mocks group.

Does this answer your question?

./alex
--
.w( the_mindstorm )p.
  TestNG co-founder
EclipseTestNG Creator

>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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: @BeforeClass behaviour

Mimil Mimil

Hi,

Yes, thank you Alex, now I perfectly understand.


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