Last active
December 15, 2015 22:39
-
-
Save passichenko/5334496 to your computer and use it in GitHub Desktop.
common api for ScalaTest FreeSpec and path.FreeSpec via abstract stuctured type
This file contains hidden or 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 test | |
| import org.scalatest._ | |
| /** | |
| * Author: Sergey V. Passichenko | |
| * Date: 08.04.13 | |
| */ | |
| class Test1 extends FreeSpec with Commons { | |
| commons() | |
| } | |
| class Test2 extends path.FreeSpec with Commons { | |
| commons() | |
| } | |
| trait Commons extends CommonFreeSpecApi { | |
| def commons() { | |
| // info in path.FreeSpec leads to exception: | |
| // ClassCastException: org.scalatest.SuperEngine$InfoLeaf cannot be cast to org.scalatest.SuperEngine$Branch | |
| //info("commons tests") | |
| "group" - { | |
| "test1" in { | |
| assert(true) | |
| } | |
| "test2" ignore { | |
| assert(false) | |
| } | |
| } | |
| } | |
| } | |
| trait CommonFreeSpecApi { | |
| protected type FreeSpecStringWrapper = { | |
| def - (fun: => Unit) | |
| def in(f: => Unit) | |
| def ignore(f: => Unit) | |
| } | |
| protected def info: Informer | |
| implicit protected def convertToFreeSpecStringWrapper(s: String): FreeSpecStringWrapper | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment