Undocumented behaviour when using option "methods" in ant

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

Undocumented behaviour when using option "methods" in ant

Arno Jost
Suppose you have a suite defined in "testng_suite.xml" containing only one class "anyTest" that itself has two methods "testA" and "testB".

Running the suite (by using a <xmlfileset>) or the class (by using <classfileset>) in ant leeds to the expected behaviour: testA and testB are executed.

The problem comes when you add the argument
  methods="anyTest.testA"
to the testng-target...

Combined with the class-argument: only testA get executed -> nice
Combined with the suite-argument: the suite (testA + testB) and  additionally testA get executed -> weird
Not combined (no suite, no class): only testA get executed -> weird, because the documentation (http://testng.org/doc/ant.html) says clearly:
"One of the attributes xmlfilesetref, classfilesetref or nested <xmlfileset>, respectively <classfileset> must be used for providing the tests."

I'm wonderung about the intended behaviour of the "methods" argument in ant.

Any help would be greatly appreciated.

Greets,
Arno

p.s. i'm using v.6.2 of testng
Reply | Threaded
Open this post in threaded view
|

Re: Undocumented behaviour when using option "methods" in ant

Cédric Beust ♔-2
Hi Arno,

The behavior becomes hard to predict when you use both command line arguments and a testng.xml file (in short, TestNG has to decide which argument should prevail, and the rules are not quite clear).

I suggest either using only command line parameters or .xml files.

-- 
Cédric




On Thu, Sep 15, 2011 at 3:57 AM, Jostar <[hidden email]> wrote:

Suppose you have a suite defined in "testng_suite.xml" containing only one
class "anyTest" that itself has two methods "testA" and "testB".

Running the suite (by using a <xmlfileset>) or the class (by using
<classfileset>) in ant leeds to the expected behaviour: testA and testB are
executed.

The problem comes when you add the argument
 methods="anyTest.testA"
to the testng-target...

Combined with the class-argument: only testA get executed -> nice
Combined with the suite-argument: the suite (testA + testB) and
additionally testA get executed -> weird
Not combined (no suite, no class): only testA get executed -> weird, because
the documentation (http://testng.org/doc/ant.html) says clearly:
"One of the attributes xmlfilesetref, classfilesetref or nested
<xmlfileset>, respectively <classfileset> must be used for providing the
tests."

I'm wonderung about the intended behaviour of the "methods" argument in ant.

Any help would be greatly appreciated.

Greets,
Arno

p.s. i'm using v.6.2 of testng
--
View this message in context: http://old.nabble.com/Undocumented-behaviour-when-using-option-%22methods%22-in-ant-tp32470683p32470683.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: Undocumented behaviour when using option "methods" in ant

Arno Jost
Hi Cédric

I agree to your point: one should never combine a testng.xml with some additional arguments for classes and/or methods (like -testClass or -methods) because it leads to some unpredictable behaviour and is quite needless as one can specify the classes or methods directly in xml.

But then, please, make a corresponding correction in the documentation.
Both the command-line docu ("...You need to specify at least one XML file describing the TestNG suite you are trying to run. Additionally, the following command-line switches are available:...") and the ant-docu ("...One of the attributes xmlfilesetref, classfilesetref or nested <xmlfileset>, respectively <classfileset> must be used for providing the tests...") clearly prescribe the use of an xml-file.

Or let me formulate this in a question:
Is the intended and supported way to run a class or method the exclusive (no testng.xml!) usage of the options "-testclass" and "-methods" in the console, respectively the element "classfileset" and attribute "methods" in ant?

Greets,
Arno

Cedric Beust wrote
Hi Arno,

The behavior becomes hard to predict when you use both command line
arguments and a testng.xml file (in short, TestNG has to decide which
argument should prevail, and the rules are not quite clear).

I suggest either using only command line parameters or .xml files.

--
Cédric




On Thu, Sep 15, 2011 at 3:57 AM, Jostar <arno.jost@hispeed.ch> wrote:

>
> Suppose you have a suite defined in "testng_suite.xml" containing only one
> class "anyTest" that itself has two methods "testA" and "testB".
>
> Running the suite (by using a <xmlfileset>) or the class (by using
> <classfileset>) in ant leeds to the expected behaviour: testA and testB are
> executed.
>
> The problem comes when you add the argument
>  methods="anyTest.testA"
> to the testng-target...
>
> Combined with the class-argument: only testA get executed -> nice
> Combined with the suite-argument: the suite (testA + testB) and
> additionally testA get executed -> weird
> Not combined (no suite, no class): only testA get executed -> weird,
> because
> the documentation (http://testng.org/doc/ant.html) says clearly:
> "One of the attributes xmlfilesetref, classfilesetref or nested
> <xmlfileset>, respectively <classfileset> must be used for providing the
> tests."
>
> I'm wonderung about the intended behaviour of the "methods" argument in
> ant.
>
> Any help would be greatly appreciated.
>
> Greets,
> Arno
>
> p.s. i'm using v.6.2 of testng
> --
> View this message in context:
> http://old.nabble.com/Undocumented-behaviour-when-using-option-%22methods%22-in-ant-tp32470683p32470683.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.