Hi Mauricio,
specs2 is a bit different than other libraries. First of all there is no "test tree" but a list of "Specification fragments".
They are of different type:
- Text
- Example
- Step
- "Formatting fragments": br, p, end, t
- ...
And basically when you org.specs2.Specification or org.specs2.mutable.Specification you inherit 2 DSLs to create those fragments:
- in org.specs2.Specification you use an "interpolated string" to create them so that your specification looks like an annotated text
- in org.specs2.mutable.Specification you use String extension methods, should / in, to create the fragments
You can however directly create your specification by creating those fragments yourself:
class MySpec extends Specification { def is =
Text("hello") ^ br ^
Example("this should work", ok)
}
This means that you can use this low-level api to create whatever Fragments you need, assemble them with the ^ operator, and use them to define the Specification.is method.
A word of caution though, this API is going to evolve with specs2 3.0 (available as 3.0-M2 right now but I'm still working on finishing a few things + the migration guide) around 3 axes:
- only one Fragment type, composed of a Description and an Execution (this covers all previous cases of Text, Example,... and more)
- some "factory" traits to create fragments, with methods like: text, example, step,...
- some DSLs traits to add syntactic sugar (for the interpolated s2 string, should / in, ...)
Perhaps you could present an example of what you wish to achieve and I can show you how to do it.
Eric.