Scala

From sheep
Revision as of 22:36, 14 September 2021 by Martin (talk | contribs) (Created page with "=Testing= ==Writing a test== <pre> import org.scalatest.{FlatSpec, Matchers} class StreamSpec extends FlatSpec with Matchers { "Stream.toList" should "convert the steam to...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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