1

Sometimes we need to mix in some traits in our test cases. However the following does not work:

"abc" should {
  "def" in new TraitA with TraitAB {
    // ...
  }    
}

To make it work, we do the following:

trait Fixture extends Before {
  def before = ()
}

"abc" should {
  "def" in new Fixture with TraitA with TraitAB {
    // ...
  }    
}

This feels somewhat hacky. Is there a better way to do it?

missingfaktor
  • 90,905
  • 62
  • 285
  • 365

1 Answers1

4

This will work if you also mix in the org.specs2.specification.Scope marker trait:

"abc" should {
  "def" in test {
    // ...
  }    
}

trait test extends TraitA with TraitAB with Scope
Eric
  • 15,494
  • 38
  • 61