Hi Frank,
>
> The graphical UI tells me, that we had 7 runs, sometimes 6, sometimes 0.
> The textui states that 2 Tests are ok. I want to see 10, because there
> are 5 tests for each user.
>
Interesting. When I run it through the graphical runner, it
consistently returns 10. Can you tell me more about how you're running
it through the graphical runner?
As for the text ui, it also consistently runs 10 tests if I run it as:
java junit.textui.TestRunner Example
If you run it via a main() method, remember to specify that you want it
to run the suite() method. So, this will run 10 tests:
public static void main(String[] args) {
junit.textui.TestRunner.run(Test.suite());
}
But this will run 2 tests:
public static void main(String[] args) {
junit.textui.TestRunner.run(Test.class);
}
To summarize, if you run a test via the command-line using the form
java junit.<text|swing>ui.TestRunner Example
then JUnit will first try to run the suite() method. If a suite()
methods doesn't exist, then JUnit creates a suite by finding all
testXXX() methods.
If you run a test via its main() method using something like
java Example
then you must qualify in the main() method whether it should run the
suite() method or create a suite automatically using reflectiong (e.g.
Test.class). I suspect this is the source of the problem you are observing.
As an aside, there's no need to directly use a ThreadedTest when using
the LoadTest. The LoadTest will use a ThreadedTest under the hood to
ensure that each user runs within their own thread. So the following
will work equally well:
public static Test suite() {
int maxUsers = 5;
return new LoadTest(new TestSuite(Example.class), maxUsers);
}
Let me know if that helps.
Regards,
Mike
--
Mike Clark
http://clarkware.com
(303) 589-3812