ScalaTest Testing Framework


Qualified supports writing test fixtures for Scala using ScalaTest.

Scala with ScalaTest Quick Start

  • Solution Code
object Sample {
  def sayHello(name: String) = {
    if (name.length() > 0)
      "Hello, " + name + "!"
      "Hello there!"
  • Test Fixture:
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.

Learn More

You can learn more on the ScalaTest website.