ScalaTest installation
http://www.scalatest.org/install
Lets modify this example (see code below):
http://www.scalatest.org/quick_start
> sbt test
sbt.build
http://www.scalatest.org/install
Lets modify this example (see code below):
http://www.scalatest.org/quick_start
> sbt test
sbt.build
/** * Created by depappas on 7/10/17. */import org.scalatest._ import scala.collection.mutable.ArrayBuffer class ExampleSpec extends FlatSpec with Matchers { class Stack[T] { val stack = new ArrayBuffer[T] def push(d: T) : Unit = { stack += d } def pop() : T = { stack.last stack.remove(stack.length - 1) } } "A Stack" should "pop values in last-in-first-out order" in { val stack = new Stack[Int] stack.push(1) stack.push(2) stack.pop() should be (2) stack.pop() should be (1) } it should "throw NoSuchElementException if an empty stack is popped" in { val emptyStack = new Stack a [NoSuchElementException] should be thrownBy { emptyStack.pop() } } }
No comments:
Post a Comment