Skip to content

Commit

Permalink
Initial structure and test examples
Browse files Browse the repository at this point in the history
Basic build script and some example tests.
  • Loading branch information
jyrkiput committed Mar 15, 2012
1 parent 0c62ad5 commit d6e1c4f
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name := "gameoflife"

version := "0.0"

organization := "org.agilefinland.oulu"


libraryDependencies ++= Seq(
"org.specs2" %% "specs2" % "1.8.2" % "test",
"org.scalatest" %% "scalatest" % "1.7.1" % "test"
)

resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",
"releases" at "http://oss.sonatype.org/content/repositories/releases"
)
3 changes: 3 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resolvers += "sbt-idea-repo" at "http://mpeltonen.github.com/maven/"

addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.0.0")
10 changes: 10 additions & 0 deletions src/main/scala/org/agilefinland/gameoflife/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.agilefinland.gameoflife

class Main {
def foo() : Int = {
0
}
}
object Main extends App {
println("Hello World!")
}
63 changes: 63 additions & 0 deletions src/test/scala/org/agilefinland/gameoflife/MainScalaTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.agilefinland.gameoflife

import org.specs2.matcher.ShouldMatchers
import org.scalatest.matchers.MustMatchers
import org.scalatest.GivenWhenThen
import org.scalatest.{FeatureSpec, FunSpec, FunSuite}

class MainScalaTest extends FunSuite {

test("foo returns 0") {
val m = new Main
assert(m.foo == 0)
}

}

class MainScalaTestShould extends FunSuite with ShouldMatchers {

test("foo returns 0") {
val m = new Main
m.foo should equalTo(0)
}
}

class MainScalaTestMust extends FunSuite with MustMatchers {

test("foo returns 0") {
val m = new Main
m.foo must equal(0)
}
}

class MainScalaTesBdd extends FunSpec with MustMatchers {

describe("A main class") {
it("should return 0 when 'foo' is called") {
val m = new Main
m.foo must equal(0)
}

it("should make coffee when 'bar' is called") ( pending )

}
}

class MainScalaTesSpec extends FeatureSpec with GivenWhenThen with MustMatchers {

info("as a programmer")
info("I want to get zero")
info("when I call 'foo'")
feature("Main::foo returns 0") {
scenario("should return 0 when 'foo' is called") {
given("A Main class")
val m = new Main
when("foo is called")
val foo: Int = m.foo
then("value must be 0")
foo must equal(0)
}


}
}
14 changes: 14 additions & 0 deletions src/test/scala/org/agilefinland/gameoflife/MainSpecs2Test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.agilefinland.gameoflife

import org.specs2.mutable.Specification

class MainSpecs2Test extends Specification {

"Main class" should {
"'foo' should return 0" in {
val m = new Main
m.foo === 0
}
}

}

0 comments on commit d6e1c4f

Please sign in to comment.