Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
cant get @beforegroups to work
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
shay  
View profile  
 More options Oct 30, 9:59 pm
From: shay <matas...@gmail.com>
Date: Fri, 30 Oct 2009 18:59:09 -0700 (PDT)
Local: Fri, Oct 30 2009 9:59 pm
Subject: cant get @beforegroups to work
Hi All,

before groups always runs after the test method

here is my code:

@Test(groups={"NewUser"})
public class RegisterCommandTest {

        Logger l = LoggerFactory.getLogger(this.getClass());

        @BeforeClass
        public void beforeClass(ITestContext itc)
        {
                l.debug("getting injector from context");
                m_inj =  (Injector) itc.getAttribute("injector");
                m_inj.injectMembers(this);

        }
        public void testExecute(ITestContext itc) throws Exception {

                l.debug("do somthing");
        }

}

public class BeforeGroupTest {

        Logger l = LoggerFactory.getLogger(this.getClass());

        @BeforeGroups(groups = { "NewUser"},value={ "NewUser"})
        public void preNewUser(ITestContext itc) {
                l.debug("perfroming pre groups init");
                m_inj = Guice.createInjector(new JUnitModule(), new RequestModule(),
                                new GenericModule(), new SecurityModule());
                itc.setAttribute("injector", m_inj);
        }

}

I am using Maven.

any advice,
Shay


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cédric Beust ♔  
View profile  
 More options Oct 31, 7:41 pm
From: Cédric Beust ♔ <cbe...@google.com>
Date: Sat, 31 Oct 2009 16:41:59 -0700
Local: Sat, Oct 31 2009 7:41 pm
Subject: Re: [testng-users] cant get @beforegroups to work

Hi,

I tried your code and it behaves as expected for me:

BEFORECLASS getting injector from context
BEFOREGROUPS perfroming pre groups init
TESTEXECUTE do somthing

===============================================
Single
Total tests run: 1, Failures: 0, Skips: 0
===============================================

Note that I ran it directly (without Maven).  Can you try without Maven as
well?

--
Cédric


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shay  
View profile  
 More options Oct 31, 7:47 pm
From: shay <matas...@gmail.com>
Date: Sat, 31 Oct 2009 16:47:36 -0700 (PDT)
Local: Sat, Oct 31 2009 7:47 pm
Subject: Re: cant get @beforegroups to work
Hi Cedric,

Thank you for you time.

Shouldn't  BEFOREGROUPS run before BEFORECLASS , as all methods of the
class belong to the group?

if @beforeclass is executed before @beforegroup  , how do you
recommend that i initiate the injector?

Thanks,
Shay

On Oct 31, 7:41 pm, Cédric Beust ♔ <cbe...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cédric Beust ♔  
View profile  
 More options Nov 1, 10:51 am
From: Cédric Beust ♔ <cbe...@google.com>
Date: Sun, 1 Nov 2009 08:51:06 -0700
Local: Sun, Nov 1 2009 10:51 am
Subject: Re: [testng-users] Re: cant get @beforegroups to work

Hi Shay,

There is no particular reason why @BeforeClass should run before
@BeforeGroups or the other way around, so you should not rely on this.  I
understand it would make sense in your situation but in other scenarios,
@BeforeClass methods have to run before @BeforeGroups.

For example, consider:

class A
  f (group "aa")
  i (group "bb")

class B
  h (group "aa")

If I run group "bb" and "aa", you would see the following order:

beforeClass A
beforeGroups bb
A.i
beforeGroups aa
A.f
beforeClass B
B.h

Back to your problem.

I don't see your m_inj field defined in any of your classes, so I'm guessing
it's static or inherited from some base class?

This field looks global enough that you might want to initialize it in a
@BeforeSuite method.  Would this solve your problem?

--
Cédric


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
shay  
View profile  
 More options Nov 3, 10:13 pm
From: shay <matas...@gmail.com>
Date: Tue, 3 Nov 2009 19:13:07 -0800 (PST)
Local: Tues, Nov 3 2009 10:13 pm
Subject: Re: cant get @beforegroups to work
Hi Cedric,

thanks that makes sense.

up until i have been avoiding an XML config , by using only
annotations . is there a way to use suites without an xml?

Thanks,
Shay

On Nov 1, 10:51 am, Cédric Beust ♔ <cbe...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Cédric Beust ♔  
View profile  
 More options Nov 3, 10:17 pm
From: Cédric Beust ♔ <cbe...@google.com>
Date: Tue, 3 Nov 2009 19:17:20 -0800
Local: Tues, Nov 3 2009 10:17 pm
Subject: Re: [testng-users] Re: cant get @beforegroups to work

Hi Shay,

If you don't use an XML file, TestNG will create its own suite to wrap your
tests, so @BeforeSuite should work for you anyway.

I'm betting that you will end up having to use an XML file as your tests
grow, though...

--
***Cédric
*


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google