On this page
ScalaTest Testing Framework
Overview
Qualified supports writing tests for Scala using ScalaTest.
Basic Example
Solution
object Sample {
def sayHello(name: String) = {
if (name.length() > 0) {
"Hello, " + name + "!"
}
else {
"Hello there!"
}
}
}
Tests
import org.scalatest._
class SampleSpec extends FlatSpec with Matchers {
behavior of "Sample.sayhello"
it should "return a greeting to given name" in {
Sample.sayHello("Qualified") should equal ("Hello, Qualified!")
}
it should "handle empty string" in {
Sample.sayHello("") should equal ("Hello there!")
}
}
ScalaTest supports many other testing styles.