How to correctly work with Scala Specs2 Notifier?
Haven't found any example to demonstrate some use cases of the Notifier trait.
Edit:
When using Notifier as follows, it works flawlessly:
class TestSpec extends TestUtils {
"Arithmetic" should {
"add two numbers" in {
1 + 1 mustEqual 2
}
"add three numbers" in {
1 + 1 + 1 mustEqual 3
}
}
}
class TestNotifier extends ConsoleNotifier
trait TestUtils extends Specification {
args.report(notifier = "com.stuff.TestNotifier")
}
But, when i'm trying to add some new context creation for each test:
class TestSpec extends TestUtils {
trait Context {
val justNum = 4
}
"Arithmetic" should {
"add two numbers" in new Context {
1 + 1 mustEqual 2
}
"add three numbers" in new Context {
1 + 1 + 1 mustEqual 3
}
}
}
errors appear:
Error:(12, 23) could not find implicit value for evidence parameter of type org.specs2.execute.AsResult[TestSpec.this.Context] "add two numbers" in new Context {
The 3.0.x documentation for Notifier
is here (and the corresponding API is there).
Basically you need to define a class implementing the Notifier
trait and then called it with the notifier
argument:
sbt> testOnly *BinarySpec* -- notifier org.acme.reporting.FtpNotifier
You can have a look at the ConsoleNotifier
for a simple example of an implementation.