[Wtr-general] Setting up before a series of tests (WAS: test/unit argument error)

marekj marekj.com at gmail.com
Wed Jun 27 21:13:47 EDT 2007


Jeff,
Watir::TestCase executes all def test_ methods sequentially by default now.
Bret has fixed it (thanks)
Just subst Watir::TestCase (which subtypes Test::Unit::TestCase)
like so...

class TC_blaghamuga < Watir::TestCase
def test_zigbat end
def test_junitox end
end

and all def test_ fixtures will run sequentially. (take a look at Watir Rdoc
for Watir::TestCase for more info)

To run TestCases sequentially I just call them individually pulling each out
of the Array hat
testscenario.each {|testcase| TestRunner.run(testcase)}

(which requires some infrastructrue:
require 'test/unit/ui/console/testrunner'
include Test::Unit::UI::Console
)

marekj

On 6/27/07, Jeff Fry <jeff.fry at gmail.com> wrote:
>
> One option is to have a setup test that you guarantee executes first.
> Something like
>
> def test_aaa_setup_environment
>   # do initial setup for the upcoming tests
> end
>
> You could of course do something similar for teardown like
>
> def test_zzz_teardown_environment
>   # do teardown stuff
> end
>
> This works because Test::Unit executes tests in alphabetical order...but
> there may be more elegant solutions as well. If folks know of them, please
> speak up.
>
> One thing I wouldn't recommend in general is to just put the initial steps
> in the current first test in your suite. This might be fine but seems
> fragile. If something else becomes the new first test, you'll need to copy
> code to the new test.
>
> Jeff
>
> On 6/26/07, Manish Sapariya <manish at gslab.com > wrote:
> >
> > Jeff Fry wrote:
> > > Happily, setup and teardown are also optional methods for those of us
> > > using Watir. If you don't want something to happen automatically at
> > > the beginning of every run, don't put it in setup. Likewise with
> > > teardown. For functional automation I often don't include these
> > > methods at all.
> > Thanks Jeff.
> > How about the case when I want to setup some environment, but that needs
> > to be done only once for a set of test cases.
> >
> > Regards,
> > Manish
> > _______________________________________________
> > Wtr-general mailing list
> > Wtr-general at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
>
>
>
> --
> http://testingjeff.wordpress.com
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070627/452cb9de/attachment.html 


More information about the Wtr-general mailing list