Skip to content

Instantly share code, notes, and snippets.

@il-kyun
Last active February 12, 2017 14:53
Show Gist options
  • Save il-kyun/e8e42ff30595bb6ca6a4f36b2ea76bc6 to your computer and use it in GitHub Desktop.
Save il-kyun/e8e42ff30595bb6ca6a4f36b2ea76bc6 to your computer and use it in GitHub Desktop.
[scala] test case : exam 1
class Adder {
def add(a: Int, b: Int): Int = {
a + b
}
}
class AdderTest extends FunSuite {
test("1 plus 2 is equals to 3") {
val adder = new Adder()
assert(adder.add(1, 2) == 3)
}
test("1 plus 2 is not equals to 4") {
val adder = new Adder()
assert(adder.add(1, 2) != 4)
}
}
import org.scalatest.{FlatSpec, Matchers}
class AdderTest1 extends FlatSpec with Matchers {
"1 plus 2" should "3" in {
val adder = new Adder()
val result = adder.add(1, 2)
result should be(3)
}
}
name := "HelloScala"
version := "1.0"
scalaVersion := "2.12.1"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment