Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Get current suite name during @Factory method call
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
  4 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
 
Curtis W  
View profile  
 More options Nov 6, 3:05 pm
From: Curtis W <galv...@gmail.com>
Date: Fri, 6 Nov 2009 12:05:27 -0800 (PST)
Local: Fri, Nov 6 2009 3:05 pm
Subject: Get current suite name during @Factory method call
I have a group of tests that are created using an @Factory method, and
are part of a larger suite that I've defined in an xml file. I'd like
these tests to run against one of several environments which are at
different URLs. For normal @Test methods this is not a problem because
in the @BeforeSuite period of testng's lifecycle I can simply call a
method in a class which has the appropriate set-up hard coded.
@Factory runs before @BeforeSuite however, so I can't rely on the same
mechanism.

Is there any way to access the testng framework dynamically to
determine which xml file was used to configure the current test run?


    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 6, 3:24 pm
From: Cédric Beust ♔ <cbe...@google.com>
Date: Fri, 6 Nov 2009 12:24:33 -0800
Local: Fri, Nov 6 2009 3:24 pm
Subject: Re: [testng-users] Get current suite name during @Factory method call

Hi Curtis,

You can tell TestNG to pass your factory an ITestContext that contains all
the information you need.

Maybe something a bit more flexible for you would be to use a parameter:

<suite name="Single" verbose="1" parallel="false" thread-count="2">

  <parameters>
    <parameter name="foo" value="bar" />
  </parameters>

  <test name="Single">
    <classes>
      <class name="test.factory.FactoryChild" />
    </classes>
  </test>

</suite>

and your factory:

  @Factory
  public Object[] create(ITestContext ctx) {
    // will print "bar"
    System.out.println("Parameter:" +
ctx.getCurrentXmlTest().getParameter("foo"));
    return new Object[] {
    // ...

Does this help?

--
Cedric

--
***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.
Curtis W  
View profile  
 More options Nov 6, 3:47 pm
From: Curtis W <galv...@gmail.com>
Date: Fri, 6 Nov 2009 12:47:39 -0800 (PST)
Local: Fri, Nov 6 2009 3:47 pm
Subject: Re: Get current suite name during @Factory method call
That works perfectly. You're a legend!

On Nov 6, 1:24 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 6, 3:51 pm
From: Cédric Beust ♔ <cbe...@google.com>
Date: Fri, 6 Nov 2009 12:51:38 -0800
Local: Fri, Nov 6 2009 3:51 pm
Subject: Re: [testng-users] Re: Get current suite name during @Factory method call

On Fri, Nov 6, 2009 at 12:47 PM, Curtis W <galv...@gmail.com> wrote:

> That works perfectly. You're a legend!

Wow, thanks :-)

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