Re: [testng-users] How to control tests running according to logic expression, such as if or loop

35 views
Skip to first unread message

Oliver Fischer

unread,
Apr 26, 2013, 6:28:29 AM4/26/13
to testng...@googlegroups.com, 孙岳
Hi,

it depends on your build tool and the source of your variable. With
Maven you could achive this by using different profiles. For that have a
look at possibilites for the activation of a Maven profile (system
property, environment variable).

Or have a look at the different listeners provided by the TestNG API.
There is a listener which can modify a suite programmatically.

Sorry I can't provide any links, since I am offline while writing this.

Bye,

Oliver

Am 25.04.2013 11:44, schrieb 孙岳:
> Hi,
> I am using TestNG 6.7 and have such requirements: I need run some tests
> in a certain condition, and skip these tests if this condition doesn't
> exist.
> Say a suite xml as following:
>
> <suite name="condition">
> <if condition="${variable}">
> <test name="test-1">
> <classes>
> <class name="sample.SampleTest"/>
> </classes>
> </test>
> </if>
> </suite>
>
> When the "variable" is true, "test-1" will be executed, otherwise
> "test-1" will be skipped. (I use an inexistent "if" tag to express my
> requirement)
> Can testng support it?
> Thank you.
>
> --
> You received this message because you are subscribed to the Google
> Groups "testng-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to testng-users...@googlegroups.com.
> To post to this group, send email to testng...@googlegroups.com.
> Visit this group at http://groups.google.com/group/testng-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Cédric Beust ♔

unread,
May 23, 2013, 3:20:58 AM5/23/13
to testng...@googlegroups.com, 孙岳
No. XML is the wrong place to do this.

-- 
Cédric


-- 
Cédric



On Thu, May 23, 2013 at 12:14 AM, 孙岳 <suny...@gmail.com> wrote:
Can TestNG add such a feature that tester can define flow control such as "if", "loop", etc in the XML suite file?
I do really need such functions.
Thank you!

在 2013年4月26日星期五UTC+8下午6时28分29秒,Oliver Fischer写道:
Reply all
Reply to author
Forward
0 new messages