Created
March 20, 2012 23:18
-
-
Save neilprosser/2142360 to your computer and use it in GitHub Desktop.
Problem combining BeforeAfter and Around context traits in Specs2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package specs2.example | |
import org.junit.runner.RunWith | |
import org.specs2.execute._ | |
import org.specs2.mutable._ | |
import org.specs2.runner.JUnitRunner | |
@RunWith(classOf[JUnitRunner]) | |
class ExampleSpec extends SpecificationWithJUnit { | |
trait MyBeforeAfter extends BeforeAfter { | |
val fromBeforeAfter = "From MyBeforeAfter" | |
def before = { | |
println("Before in MyBeforeAfter") | |
} | |
def after = { | |
println("After in MyBeforeAfter") | |
} | |
} | |
trait MyAround extends Around { | |
val fromAround = "From MyAround" | |
def around[T <% Result](t: => T) = { | |
println("Before in MyAround") | |
val result = t | |
println("After in MyAround") | |
result | |
} | |
} | |
"My example spec" should { | |
// This doesn't compile | |
// overriding method apply in trait BeforeAfter of type [T](a: => T)(implicit evidence$1: T => org.specs2.execute.Result)org.specs2.execute.Result; method apply in trait Around of type [T](a: => T)(implicit evidence$2: T => org.specs2.execute.Result)org.specs2.execute.Result needs `override' modifier | |
/*"work when combining MyBeforeAfter and MyAround" in new MyBeforeAfter with MyAround { | |
println("Start of first test") | |
println("=================") | |
println(fromBeforeAfter) | |
println(fromAround) | |
println("=================") | |
println("End of first test") | |
}*/ | |
"work when combining MyAround and MyBeforeAfter" in new MyAround with MyBeforeAfter { | |
println("Start of second test") | |
println("=================") | |
println(fromBeforeAfter) | |
println(fromAround) | |
println("=================") | |
println("End of second test") | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before in MyBeforeAfter | |
Start of second test | |
================= | |
From MyBeforeAfter | |
From MyAround | |
================= | |
End of second test | |
After in MyBeforeAfter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment