Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
iterator behaviour
Max Russell
12/20/2006 4:54:00 PM
I have a harness I'm using for testing with Watir. It has become
apparent that the iterator is loading the tests defined based on the
order they appear in the directory as opposed to the order in the
testlist.
File.open('testlist.txt').each_line do |entry|
self.send(:define_method, entry.strip){ load "#{entry.strip}.rb"}
so if the testlist read something like
test_aac
test_aab
test_aaa
instead of executing them in the order above it would do
test_aaa
test_aab
test_aac
I'm probably being thick, but I'm not spotting where my iterator is
going wrong?
--
Posted via
http://www.ruby-...
.
2 Answers
Brad Phelan
12/21/2006 8:25:00 AM
0
Max Russell wrote:
> I have a harness I'm using for testing with Watir. It has become
> apparent that the iterator is loading the tests defined based on the
> order they appear in the directory as opposed to the order in the
> testlist.
>
> File.open('testlist.txt').each_line do |entry|
> self.send(:define_method, entry.strip){ load "#{entry.strip}.rb"}
>
>
> so if the testlist read something like
>
> test_aac
> test_aab
> test_aaa
>
> instead of executing them in the order above it would do
>
> test_aaa
> test_aab
> test_aac
>
> I'm probably being thick, but I'm not spotting where my iterator is
> going wrong?
>
There is nothing wrong with your iterator here. However what
you are doing with your iterator is calling define_method
which will generate methods ( presumably test methods )
inside your test class.
I am guessing that the test framework is agnostic as to
the order you define methods. It would probably pull them
off the class with
Class:instance_methods
which I will probably generate a list in alphabetical order
which is what you see.
--
Brad Phelan
http://xt...
Max Russell
12/22/2006 11:14:00 AM
0
I'm doing the ugly thing just now and using something like this
test_001_aaa
test_002_aac
test_003_aab
obviously this isn't nice as it necessitates retaining a mapping of
tests to order, which is what I wanted to avoid. I had wanted to be able
to select lists of *any* tests in any order, thus creating suites out of
arbitrary test components.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
iterator behaviour
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password