@@ -20,15 +20,15 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
20
20
1 . Add the ScalaTest dependency:
21
21
1 . Add the ScalaTest dependency to your ` build.sbt ` file:
22
22
```
23
- libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8 " % Test
23
+ libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11 " % Test
24
24
```
25
25
1. If you get a notification "build.sbt was changed", select **auto-import**.
26
26
1. These two actions will cause `sbt` to download the ScalaTest library.
27
- 1. Wait for the `sbt` sync to finish; otherwise, `FunSuite ` and `test()` will be
27
+ 1. Wait for the `sbt` sync to finish; otherwise, `AnyFunSuite ` and `test()` will be
28
28
unrecognized.
29
29
1. On the project pane on the left, expand `src` => `main`.
30
30
1. Right-click on `scala` and select **New** => **Scala class**.
31
- 1. Call it `CubeCalculator`, change the **Kind** to `object`, and click **OK** .
31
+ 1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double click on `object` .
32
32
1. Replace the code with the following:
33
33
```
34
34
object CubeCalculator extends App {
@@ -41,12 +41,12 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
41
41
## Creating a test
42
42
1. On the project pane on the left, expand `src` => `test`.
43
43
1. Right-click on `scala` and select **New** => **Scala class**.
44
- 1. Name the class `CubeCalculatorTest` and click **OK** .
44
+ 1. Name the class `CubeCalculatorTest` and hit enter or double click on `class` .
45
45
1. Replace the code with the following:
46
46
```
47
- import org.scalatest.FunSuite
47
+ import org.scalatest.funsuite.AnyFunSuite
48
48
49
- class CubeCalculatorTest extends FunSuite {
49
+ class CubeCalculatorTest extends AnyFunSuite {
50
50
test("CubeCalculator.cube") {
51
51
assert(CubeCalculator.cube(3) === 27)
52
52
}
@@ -60,9 +60,9 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
60
60
Let's go over this line by line:
61
61
62
62
* `class CubeCalculatorTest` means we are testing the object `CubeCalculator`
63
- * `extends FunSuite ` lets us use functionality of ScalaTest's FunSuite class
63
+ * `extends AnyFunSuite ` lets us use functionality of ScalaTest's AnyFunSuite class
64
64
such as the `test` function
65
- * `test` is function that comes from the FunSuite library that collects
65
+ * `test` is a function that comes from the FunSuite library that collects
66
66
results from assertions within the function body.
67
67
* `"CubeCalculator.cube"` is a name for the test. You can call it anything but
68
68
one convention is "ClassName.methodName".
0 commit comments