Paul King <email@example.com>
Wed, 20 Dec 2006 21:15:58 +1000
It would not normally be recommended that you try to run all
100 tests as part of the same webtest element. You can have
multiple webtest elements and combine them all at the reporting
level. This helps with test isolation.
If you want to selectively run webtest elements you can place them
inside a target with an "if" or "unless" attribute. Ant normally
doesn't let you set a property twice, so you can't have it true
then later false. You can however have it undefined and later
defined. Alternatively, if you don't mind bending Ant practice
a tiny bit use something like the ant-contrib tasks (or a little
bit of groovy) to alter an Ant property.
The ifstep is useful if you want to selectively run steps within
one webtest. In your scenario you could possibly use a <repeat>
step and have a condition for the ifstep based on #count. I think
there was an issue with webtest variables inside repeats for a while
but I think it is fixed. This would be a possible way to go if you
are planning to change the database within the loop.
You can do your database steps using Ant's sql task or if you want
webtest compatible reporting with sqlunit or you could use Groovy
code as well if you wanted.
Ryan Keeling wrote:
> Hi guys
> Would like to get your thoughts on something I am trying.
> I would like to test my page with data in the database, which will
> produce one type of view, then I would like to clear the database and
> test the page properly displays, usually a message such as "No data
> found to display". I would like to do this as part of the same webtest
> script using an ifstep. I have 100 tests and I would like to run through
> them all first testing the pages with data in the db, then change a
> property so the second part of the ifstep in each test executes, testing
> the page with no data in the db.
> basically like this
> <if db.populated=true>
> run test a
> <if db.populated=false>
> run test b
> My problem is that I cant seem to set a global property which can be
> seen by all 100 test scripts, ideally I would like to set a property in
> my main build file which calls all scripts then change this after the
> last one has run to run them all again satisfying test b.
> Is there an easier way of doing this that I may have overlooked?
> WebTest mailing list