diff options
Diffstat (limited to 'examples/scalatest-example')
4 files changed, 47 insertions, 0 deletions
diff --git a/examples/scalatest-example/build/build.scala b/examples/scalatest-example/build/build.scala new file mode 100644 index 0000000..48248fd --- /dev/null +++ b/examples/scalatest-example/build/build.scala @@ -0,0 +1,9 @@ +import cbt._ +class Build(val context: Context) extends SbtLayoutMain { + outer => + override def test: Option[ExitCode] = Some{ + new BasicBuild(context) with ScalaTest with SbtLayoutTest{ + override def dependencies = outer +: super.dependencies + }.run + } +} diff --git a/examples/scalatest-example/build/build/build.scala b/examples/scalatest-example/build/build/build.scala new file mode 100644 index 0000000..d641b51 --- /dev/null +++ b/examples/scalatest-example/build/build/build.scala @@ -0,0 +1,8 @@ +import cbt._ + +class Build(val context: Context) extends BuildBuild{ + override def dependencies = super.dependencies ++ Seq( + plugins.scalaTest, + plugins.sbtLayout + ) +} diff --git a/examples/scalatest-example/src/main/scala/Hello.scala b/examples/scalatest-example/src/main/scala/Hello.scala new file mode 100644 index 0000000..099a84d --- /dev/null +++ b/examples/scalatest-example/src/main/scala/Hello.scala @@ -0,0 +1,7 @@ +object Main extends App{ + + println("Hello World") + + def square(x: Int) = x * x + +} diff --git a/examples/scalatest-example/src/test/scala/Test.scala b/examples/scalatest-example/src/test/scala/Test.scala new file mode 100644 index 0000000..48b0a36 --- /dev/null +++ b/examples/scalatest-example/src/test/scala/Test.scala @@ -0,0 +1,23 @@ +import collection.mutable.Stack +import org.scalatest._ + +class Test extends FlatSpec with Matchers { + "square" should "return double" in { + Main.square(2) should be (4) + } + + "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[Int] + a [NoSuchElementException] should be thrownBy { + emptyStack.pop() + } + } +}
\ No newline at end of file |