Can you clarify what you mean by "configuration"? Is it different
objects the test runs need? Different external setup? Something else?
Thanks.
Bill
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
>
--
Bill Venners
Artima, Inc.
http://www.artima.com
Do you want to pick only one configuration for each run? In other
words, do you want a suite of tests that you can either run with an
in-memory database or a staging database, etc.? If that's what you're
after then you probably want to use ScalaTest's ConfigMap. This is
something that gets passed around for the purpose of configuring
tests. You could put entries in there for which DDL to use and which
database to use, for example, and your tests could use that. You can
pass any objects in the config map, and you can put strings in it via
Runner's command line.
On the other hand, you may want to reuse the same test code with
multiple configurations during the same run. If that's what your
after, one thing to look at is ScalaTest's support for shared tests.
Look in the ScalaDoc at the trait your using (Spec or FlatSpec, etc.).
That isn't the only way to do that kind of thing, though. If, for
example, you want to run each test in a suite of tests twice, you can
override withFixture and call test() twice. You can change the
configuration before each invocation of test(). Or if you'd rather set
one configuration, then run all the tests in that suite, then set
another configuration, then run all the tests again, you'd do that by
overriding runTests and implementing that behavior. If you want to do
this kind of thing in multiple suites, you'd pull that overridden
withFixture or runTests method out into a trait that you mix into any
suite you want to have this behavior.
Does something in those ideas sound like a good fit for your needs?
Bill
Thanks for your post. That's a nice use of MultipleFixtureWordSpec.
I may be misunderstanding Alex's request, but I think he wants to run
the same tests with different fixtures. Whereas
MultipleFixtureWordSpec is more for helping you run different tests in
the same suite with different fixtures. I tried to address both of
these needs in ScalaTest.
So for example if you have tests A, B, and C, and fixtures X, Y, and
Z. Then MultipleFixtureWordSpec can help you do something like AX, BY,
and CZ. I.e, each test can declare which fixture it needs. Whereas
shared tests would help you do AX, BX, CX, AY, BY, CY, AZ, BZ, CZ.
Each test would be run multiple times, once with each fixture.
Bill
Sorry I just noticed these emails, which means I somehow managed to go
several hours without checking email. No wonder I feel relaxed.
Anyway, do you mind posting the entire class? I'm not sure I can grok
exactly what you're trying to do, but I am hopeful there's a
sweet-smelling way to do it.
If you don't want to post the whole thing, let me ask a couple pointed
questions. Does each test need two fixture objects, testData and
table? Sounds like it. And then you want to run tests multiple times
such that testData is initialized with a different data source each
time? And from your earlier emails I think you want to run each test
with each datasource. Is that correct?
Ah, but there are also some other fixture objects you called "shared
states" in one of your emails, and those are only needed by some (2 of
the total 19) methods.
If I've got this right, then, you actually want to do AX, BX, AY, BY
(the different data sources) thing, as well as the AX, BY thing (the
shared states needed by 2 tests).
Can you confirm that's correct (and post the whole class if you don't
mind)? If so I can make some suggestions.
Thanks.
Bill