libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.9" % Test
scala
import org.scalatest.funsuite.AnyFunSuite
class MathFunctionsTest extends AnyFunSuite {
test("Factorial of 0 should be 1") {
val result = MathFunctions.factorial(0)
assert(result == 1)
}
test("Factorial of a positive number should be calculated correctly") {
val result = MathFunctions.factorial(5)
assert(result == 120)
}
test("Fibonacci of 0 should be 0") {
val result = MathFunctions.fibonacci(0)
assert(result == 0)
}
test("Fibonacci of a positive number should be calculated correctly") {
val result = MathFunctions.fibonacci(6)
assert(result == 8)
}
}
sbt test