Scala

From sheep
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Testing

Writing a test

import org.scalatest.{FlatSpec, Matchers}

class StreamSpec extends FlatSpec with Matchers {
  "Stream.toList" should "convert the steam to a List" in {
    Stream(1, 2, 3, 4).toList shouldBe List(1, 2, 3, 4)
  }

Running a single test in sbt

 test-only ch5.StreamSpec -- -t "test name"

note a spec with "thing" should "perform trick" will have a name "thing should preform trick" - drop the quotes in the middle