Skip to content

Instantly share code, notes, and snippets.

@passichenko
Last active December 15, 2015 22:39
Show Gist options
  • Select an option

  • Save passichenko/5334496 to your computer and use it in GitHub Desktop.

Select an option

Save passichenko/5334496 to your computer and use it in GitHub Desktop.
common api for ScalaTest FreeSpec and path.FreeSpec via abstract stuctured type
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