I'm used to JUnit, in JUnit it is possible to group several tests (usually related to a class) just by defining these tests in a single file (class) and annotating them with @Test
. Then, to run several of these tests, a TestSuite
is created with @Suite.SuiteClasses
and so on.
In specs2 it is possible to group several tests at two different levels extending some Specification
. For example:
"Whatever" should {
"do its job when possible" in {
whatever(new Thing).work must beSome
}
"return none when not possible" in {
whatever(null).work must beNone
}
}
We can group several Specification
of this type in a single file, and each one of them can pack several checks, each check would be like a @Test
, each group like a file in JUnit and then each Specification
as a Suite
in JUnit, except a Suite
is splitted into several classes and a Specification
is in a single class (i.e. file), which tends to produce huge files.
So the question is two fold:
- Where should I put the stuff as a matter of organization and readability: a
Specification
and the things that each class should do, i.e. the checks that it should pass. - If the whole group of tests is split into several files, how can I create a
Suite
that groups them if possible in a hierarchical way, e.g. asSuites
for ScalaTest.
BTW: I'm using Specs2 because I think it is the standard (was by default with the archetype, a (very reduced) small (and anecdotal) sample corroborates this [1, 2]), but I am considering to use ScalaTest. Judging by numbers (specs2, scalatest) that may be the best option to follow standards and customs of the Scala community. I mention this because an answer like "it's not possible, use ScalaTest" would be acceptable for these reasons.