Nested Suites

872 views
Skip to first unread message

Erik Peterson

unread,
Jul 12, 2011, 6:00:32 PM7/12/11
to scalate...@googlegroups.com
Following the trait Suites doc I created the following but get an ...
"error: ';' expected but ',' found.
new ASuite,"

Tried other arrangements but no success yet.

Code...
import org.scalatest.{FunSuite, Suites}

class MasterTestSuite extends Suites {
  new ASuite,
  new BSuite,
  new CSuite
}

class ASuite extends FunSuite {
  test("test A1") {
    assert(true === true)
  }
}

class BSuite extends FunSuite {
  test("test B1") {
    assert(true === true)
  }
}

class CSuite extends FunSuite {
  ignore("test C1") {
    assert(true === false)
  }
}

Bill Venners

unread,
Jul 12, 2011, 6:58:13 PM7/12/11
to scalate...@googlegroups.com
Hi Erik,

Sorry, bug in the documentation. Those curly braces need to be parens.
This will work:

import org.scalatest.Suite
import org.scalatest.Suites

class StepsSuite extends Suites(
new Step1Suite,
new Step2Suite,
new Step3Suite,
new Step4Suite,
new Step5Suite
)

class Step1Suite extends Suite
class Step2Suite extends Suite
class Step3Suite extends Suite
class Step4Suite extends Suite
class Step5Suite extends Suite

The reason is that Scala only lets you pass one arg between curly
braces. To pass more than one arg separate by commas, you always need
to use parens. I'll update the scaladoc.

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

Erik Peterson

unread,
Jul 12, 2011, 7:32:18 PM7/12/11
to scalate...@googlegroups.com
Great thank you. This allows "soft" dependencies. Is there a way to configure "hard" dependencies between tests/suites such that dependent tests won't run unless their "parent" succeeds?

Bill Venners

unread,
Jul 12, 2011, 8:06:55 PM7/12/11
to scalate...@googlegroups.com
Hi Erik,

Not off the shelf at the moment other than using TestNGSuite or
overriding one of the lifecycle methods. Dependent tests is something
I wanted to wait on until I had some real use cases in front of me.
Can you let me know exactly what it is you'd like to do? Do you want
to have a way, for example, to say just run this test if another test
passes? Or do you want, perhaps, to be able to say don't run this
entire suite unless all of another suite passes? What's the use case?

Thanks.

Bill

Erik Peterson

unread,
Jul 12, 2011, 11:12:58 PM7/12/11
to scalate...@googlegroups.com
Good question. I'll try to get more details on the use case and its frequency. I'm presenting ScalaTest to several internal test groups as well as UseScala.org Aug 4th (unless you are in the Salt Lake City neighborhood then and want to take my place?). So thanks for helping me get up to speed.

Bill Venners

unread,
Jul 12, 2011, 11:21:44 PM7/12/11
to scalate...@googlegroups.com
Hi Erik,

OK. One way this could be done is by passing status around in the
configMap. A particular failed test, for example, could cause some
flag to be set in the configMap, and passed down to nested suites.
Those suites could decide to not execute dependent tests. This could
be implemented via traits that get mixed in, and maybe some abstract
member that gets filled in declaring dependencies, or something like
that. Could be done other ways too. But as I said, I'd love to hear
about real use cases from users before setting out to design
something.

Bill

Erik Peterson

unread,
Jul 14, 2011, 5:16:56 PM7/14/11
to scalate...@googlegroups.com
Bill,
Feedback here is that while nested suite testing is not used frequently, it is high value when needed. In a large, time consuming test suite it is helpful to fail fast and discontinue the test run. Could also be used to run "alternate" tests based on failure of high level tests.

Sounds like a good way to provide this feature. What would the syntax look like? Something like...

class FunTest extends FunSuite  with Nested {
 dependsOn(t1,t2,t3)

 test("Value is even") { assert(4 % 2 === 0)}
}
Reply all
Reply to author
Forward
0 new messages