Parallel testing

183 views
Skip to first unread message

Jan

unread,
Nov 3, 2011, 3:33:56 PM11/3/11
to scalatest-users
Hi,
Would there be any option how to control how parallel tests are
executed? In our current project test cycle takes 15mins to run which
is a bit too much. Parallel testing would be an option but we would
need need to have detailed control of the ordering. Being a db centric
app, we can not execute the tests in any order without conflicts. What
we would need is to somehow define 'workflows' (containing packages)
that are executed sequentially.
Is there anything even remotely similar or what would be the place to
start if we would build up one ourselves?

-jan

Bill Venners

unread,
Nov 3, 2011, 4:37:06 PM11/3/11
to scalate...@googlegroups.com
Hi Jan,

Yes, ScalaTest is designed for exactly that sort of thing. By default
everything is executed sequentially, but you can pass -c to Runner to
get parallel execution of suites. The way that works is the runner
passes in a defined distributor when it calls run on suites. By
default, tests are always executed sequentially. If you mix in
ParallelTestExecution, you get parallel execution of tests when a
distributor is passed. You probably don't want that. What you want is
called SequentialNestedSuiteExecution:

http://scalatest.org/scaladoc/1.6.1/#org.scalatest.SequentialNestedSuiteExecution

If you mix that into a suite, then its nested suites are executed
sequentially. That's how you build up your "workflows".

If you want to use discovery to discover suites, you'll need to
disable discovery for the nested suites you want to run sequentially>
The way to do that in 1.6.1 is to put a one-arg constructor in there,
so there won't be a no-arg constructor. Then have your "workflow"
suite just create them with some unused parameter. ScalaTest won't
discover suites that lack a no-arg constructor. In 2.0 I was thinking
I'd add a DoNotDiscover annotation for this purpose, but I still need
to figure out how to get sbt to not discover such things. Anyway, if
you don't use discovery, this isn't an issue.

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

Jan

unread,
Nov 3, 2011, 6:25:19 PM11/3/11
to scalatest-users
Brilliant!

(Actually I did read about this from the api doc but I did not get it
in that detail. But now I see that the parallelism can really be used
for our purpose as well)

This is really great. Many thanks.

-jan


On Nov 3, 10:37 pm, Bill Venners <b...@artima.com> wrote:
> Hi Jan,
>
> Yes, ScalaTest is designed for exactly that sort of thing. By default
> everything is executed sequentially, but you can pass -c to Runner to
> get parallel execution of suites. The way that works is the runner
> passes in a defined distributor when it calls run on suites. By
> default, tests are always executed sequentially. If you mix in
> ParallelTestExecution, you get parallel execution of tests when a
> distributor is passed. You probably don't want that. What you want is
> called SequentialNestedSuiteExecution:
>
> http://scalatest.org/scaladoc/1.6.1/#org.scalatest.SequentialNestedSu...
Reply all
Reply to author
Forward
0 new messages