@@ -11,7 +11,7 @@ redirect_from: "/getting-started-sbt-track/testing-scala-with-sbt-on-the-command
1111
1212There are multiple libraries and testing methodologies for Scala,
1313but in this tutorial, we'll demonstrate one popular option from the ScalaTest framework
14- called [ FunSuite ] ( https://www.scalatest.org/getting_started_with_fun_suite ) .
14+ called [ AnyFunSuite ] ( https://www.scalatest.org/scaladoc/3.2.2/org/scalatest/funsuite/AnyFunSuite.html ) .
1515We assume you know [ how to create a Scala project with sbt] ( getting-started-with-scala-and-sbt-on-the-command-line.html ) .
1616
1717## Setup
@@ -46,9 +46,9 @@ sbt test
4646named after the object we're testing.
4747
4848```
49- import org.scalatest.FunSuite
49+ import org.scalatest.funsuite.AnyFunSuite
5050
51- class CubeCalculatorTest extends FunSuite {
51+ class CubeCalculatorTest extends AnyFunSuite {
5252 test("CubeCalculator.cube") {
5353 assert(CubeCalculator.cube(3) === 27)
5454 }
@@ -58,9 +58,9 @@ named after the object we're testing.
5858Let's go over this line by line.
5959
6060* ` class CubeCalculatorTest ` means we are testing the object ` CubeCalculator `
61- * ` extends FunSuite ` lets us use functionality of ScalaTest's FunSuite class
61+ * ` extends AnyFunSuite ` lets us use functionality of ScalaTest's AnyFunSuite class
6262such as the ` test ` function
63- * ` test ` is function that comes from FunSuite that collects
63+ * ` test ` is function that comes from AnyFunSuite that collects
6464results from assertions within the function body.
6565* ` "CubeCalculator.cube" ` is a name for the test. You can call it anything but
6666one convention is "ClassName.methodName".
@@ -71,8 +71,10 @@ indeed 27. The `===` is part of ScalaTest and provides clean error messages.
7171## Adding another test case
72721 . Add another test block with its own ` assert ` statement that checks for the cube of ` 0 ` .
7373
74- ```
75- class CubeCalculatorTest extends org.scalatest.funsuite.AnyFunSuite {
74+ ```
75+ import org.scalatest.funsuite.AnyFunSuite
76+
77+ class CubeCalculatorTest extends AnyFunSuite {
7678 test("CubeCalculator.cube 3 should be 27") {
7779 assert(CubeCalculator.cube(3) === 27)
7880 }
0 commit comments