[Eclipse] Generated testng-customsite.xml does not include all parameters

1,539 views
Skip to first unread message

desolat

unread,
Jan 26, 2011, 8:55:56 AM1/26/11
to testng-users
Hi,

in my DataProviders I'm using the dependency injection feature to get
parameters there:

@DataProvider(name = "provideSome")
public static Object[][] provideSome(ITestContext context) {
XmlTest xmlTest = context.getCurrentXmlTest();
return new Object[][] {{ xmlTest.getParameter("some_parameter")}};
}

When running a TestNG test class run a testng-customsuite.xml gets
generated and is used as base for this run. But this includes only the
parameters used in the test methods of the class to run. So the
parameters for the DataProvider are not included!

Any way to get around this? Should I file a bug?

Btw. there's a long list of Eclipse related bugs in JIRA, is work
going into this right now?

Feel free to get back to me for further details,

regards,
Chris

desolat

unread,
Jan 26, 2011, 8:58:05 AM1/26/11
to testng-users
Forgot to tell: WinXP Pro SP3, Eclipse 3.6 SR1, TestNG plugin
5.14.6.20110125_1620

Chris

Cédric Beust ♔

unread,
Jan 26, 2011, 10:16:44 AM1/26/11
to testng...@googlegroups.com
Hi Chris,

I'm not sure I understand the problem but it sounds like the Eclipse plug-in's  "Template XML" feature might be what you are looking for. Doc here.

If this doesn't help, can you rephrase your problem?

And yes, I work on the plug-in on a regular basis (I actually pushed a new version yesterday with a new feature that lets you right click on a class and create a TestNG class for it).

-- 
Cédric



Chris

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




--
Cédric


desolat

unread,
Jan 26, 2011, 11:20:06 AM1/26/11
to testng-users
Hi Cedric,

let's try it again:

On Jan 26, 4:16 pm, Cédric Beust ♔ <ced...@beust.com> wrote:
> Hi Chris,
>
> I'm not sure I understand the problem but it sounds like the Eclipse
> plug-in's  "Template XML" feature might be what you are looking for. Doc
> here <http://testng.org/doc/eclipse.html#eclipse-listeners>.

I know about that feature. But there's another problem with this: if
I'm having an Eclipse workspace with different Java projects they're
all gone use the same template XML. I'd like to configure that on a
project level!

> If this doesn't help, can you rephrase your problem?

I think, you understood what my code example does, right? Imagine a
Test Class including this provider and some test methods. For this
class I choose in Eclipse "Run As -> TestNG Test". The plugin asks me
about the testng.xml file I want to use. I select the one I want with
a lot of parameters. Some of them are uses with @Parameters in the
test methods. Some other ones are only used in the DataProvider the
way I wrote in the beginning.

If I start that TestNG run configuration now I saw that the parameters
for the test methods where correct but the parameters in the
DataProvider could not be found. Debugging the test run I found out
that the plugin creates a testng-customsuite.xml which it uses (can be
found in the users temp folder). Looking at it I noticed that it only
included the parameters used in the test methods and not the ones used
only in the DataProvider. And these I'm missing.

Why are not all parameters of the file selected when creating the run
configuration in that generated xml file? Why can't I change the
testng.xml for a run configuration in the Eclipse run configuration
dialog?

I hope that helps.

Regards,
Chris

Cédric Beust ♔

unread,
Jan 26, 2011, 12:47:22 PM1/26/11
to testng...@googlegroups.com
On Wed, Jan 26, 2011 at 8:20 AM, desolat <christoph...@gmail.com> wrote:
Hi Cedric,

let's try it again:

On Jan 26, 4:16 pm, Cédric Beust ♔ <ced...@beust.com> wrote:
> Hi Chris,
>
> I'm not sure I understand the problem but it sounds like the Eclipse
> plug-in's  "Template XML" feature might be what you are looking for. Doc
> here <http://testng.org/doc/eclipse.html#eclipse-listeners>.

I know about that feature. But there's another problem with this: if
I'm having an Eclipse workspace with different Java projects they're
all gone use the same template XML. I'd like to configure that on a
project level!

Ok, and this would completely solve your problem?

--
Cédric


desolat

unread,
Jan 27, 2011, 3:06:33 AM1/27/11
to testng-users
> > On Jan 26, 4:16 pm, Cédric Beust ♔ <ced...@beust.com> wrote:
> > > Hi Chris,
>
> > > I'm not sure I understand the problem but it sounds like the Eclipse
> > > plug-in's  "Template XML" feature might be what you are looking for. Doc
> > > here <http://testng.org/doc/eclipse.html#eclipse-listeners>.
>
> > I know about that feature. But there's another problem with this: if
> > I'm having an Eclipse workspace with different Java projects they're
> > all gone use the same template XML. I'd like to configure that on a
> > project level!
>
> Ok, and this would completely solve your problem?

Not really. It would be a step in the right direction. But also the
possibility of re-configuring the used XML file of a run configuration
is needed.

But could you answer my questions from the previous mail please?
Especially why not all parameters of the choosen testng.xml are used
in the testng-customsuite.xml!

Thanks,
Chris

desolat

unread,
Feb 4, 2011, 4:27:47 AM2/4/11
to testng...@googlegroups.com
Hi Cedric

would you be so kind to answer my question from the previous mail? Why are not all parameters of the choosen testng.xml used
in the testng-customsuite.xml?

Thanks,
Chris

Cédric Beust ♔

unread,
Feb 4, 2011, 12:41:06 PM2/4/11
to testng...@googlegroups.com
It looks like the solution to this would be to add a new field to the run configuration dialog where you would indicate which testng.xml file to get the parameters from.

Did I understand correctly?

-- 
Cédric


Chris

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




--
Cédric


desolat

unread,
Feb 8, 2011, 9:19:26 AM2/8/11
to testng...@googlegroups.com
Hi Cedric,


On Friday, February 4, 2011 6:41:06 PM UTC+1, Cedric wrote:
> It looks like the solution to this would be to add a new field to the run configuration dialog where you would indicate which testng.xml file to get the parameters from.
> Did I understand correctly?

no, the main issue here is that I need all parameters from the testng.xml in the test run. Not only the ones used in some @Parameters annotation!

Chris

Cédric Beust ♔

unread,
Feb 8, 2011, 12:45:39 PM2/8/11
to testng...@googlegroups.com
When you specify an XML template file, all the parameters defined in that XML file are made available to the test you are running. If you're seeing something different, please show me your XML file and a short Java class.

--
Cédric


Cédric Beust ♔

unread,
Mar 29, 2011, 4:03:48 PM3/29/11
to rnemeth, testng...@googlegroups.com, desolat
Hi Christoph and Roland,

I just tested and parameters seem to work for me. Here is what I did.

First, specify an XML template globally (not on the project). This XML file defines the following parameter:

<suite name="SingleSuite" verbose="2" parallel="false" thread-count="4"

    data-provider-thread-count="3">


  <parameter name="n" value="42" />


My test method:

  @Test

  public void btest1(ITestContext c) {

    System.out.println("B.btest1 parameter:" + c.getCurrentXmlTest().getParameter("n"));

  }


Then I right click on this class and select "Run as... TestNG test", and the output shows that the parameter was found:

B.btest1: parameter:42


To confirm, I looked at the temporary XML file that was generated:

$ cat /private/var/folders/2B/2BTas5adErSfcduaLOvo6U+++TM/-Tmp-/testng-eclipse-1566632353/testng-customsuite.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite configfailurepolicy="skip" thread-count="4" verbose="2" name="SingleSuite" skipfailedinvocationcounts="false" junit="false" parallel="false" data-provider-thread-count="3">
  <listeners>
    <listener class-name="test.tmp.BListener"/>
  </listeners>
  <parameter name="n" value="42"/>
  <test verbose="2" name="Default test">
    <classes>
      <class name="test.tmp.B"/>
    </classes>
  </test>
</suite>

You will notice the line in bold showing that the parameter was successfully copied from the template XML file.

Can you try all these steps on a fresh workspace and report back?

Thanks.

-- 
Cédric


2011/3/24 rnemeth <rneme...@yahoo.com>
Hi Cedric,

I have the same problem, that the generated testng-customsite.xml does
not include any parameters. I am using Eclipse and let the
testng.xml generated by Eclipse and added my parameters, which I would
like to use in the java code, but instead of using the testng.xml
file in the project folder an empty generated testng-customsite.xml is
used while run as a TestNG Test.
I am new to TestNG, maybe I have a configuration problem.
Could you please help me?

 

Thanks,
Roland



On Feb 4, 6:41 pm, Cédric Beust ♔ <ced...@beust.com> wrote:
> It looks like the solution to this would be to add a new field to the run
> configuration dialog where you would indicate which testng.xml file to get
> the parameters from.
>
> Did I understand correctly?
>
> --
> Cédric
>

> > .
> > For more options, visit this group at
> >http://groups.google.com/group/testng-users?hl=en.
>
> --
> Cédric



--
Cédric


Reply all
Reply to author
Forward
0 new messages