Last active
February 12, 2017 14:53
-
-
Save il-kyun/e8e42ff30595bb6ca6a4f36b2ea76bc6 to your computer and use it in GitHub Desktop.
[scala] test case : exam 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Adder { | |
def add(a: Int, b: Int): Int = { | |
a + b | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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