Skip to content

Commit 4e48e55

Browse files
authored
Merge pull request scala#2377 from scala/issue-2376
2 parents 38b52e5 + 9ac6061 commit 4e48e55

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

_getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
2020
1. Add the ScalaTest dependency:
2121
1. Add the ScalaTest dependency to your `build.sbt` file:
2222
```
23-
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % Test
23+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test
2424
```
2525
1. If you get a notification "build.sbt was changed", select **auto-import**.
2626
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
2828
unrecognized.
2929
1. On the project pane on the left, expand `src` => `main`.
3030
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`.
3232
1. Replace the code with the following:
3333
```
3434
object CubeCalculator extends App {
@@ -41,12 +41,12 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
4141
## Creating a test
4242
1. On the project pane on the left, expand `src` => `test`.
4343
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`.
4545
1. Replace the code with the following:
4646
```
47-
import org.scalatest.FunSuite
47+
import org.scalatest.funsuite.AnyFunSuite
4848
49-
class CubeCalculatorTest extends FunSuite {
49+
class CubeCalculatorTest extends AnyFunSuite {
5050
test("CubeCalculator.cube") {
5151
assert(CubeCalculator.cube(3) === 27)
5252
}
@@ -60,9 +60,9 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
6060
Let's go over this line by line:
6161
6262
* `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
6464
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
6666
results from assertions within the function body.
6767
* `"CubeCalculator.cube"` is a name for the test. You can call it anything but
6868
one convention is "ClassName.methodName".

_overviews/scala-book/sbt-scalatest-bdd.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class MathUtilsSpec extends FunSpec {
6969

7070
As you can see, this is a very different-looking style than the TDD tests in the previous lesson. If you’ve never used a BDD style of testing before, a main idea is that the tests should be relatively easy to read for one of the “domain experts” who work with the programmers to create the application. A few notes about this code:
7171

72-
- It uses the `FunSpec` class where the TDD tests used `FunSuite`
72+
- It uses the `AnyFunSpec` class where the TDD tests used `AnyFunSuite`
7373
- A set of tests begins with `describe`
7474
- Each test begins with `it`. The idea is that the test should read like, “It should do XYZ...,” where “it” is the `double` function
7575
- This example also shows how to mark a test as “pending”
@@ -95,7 +95,7 @@ With those files in place you can again run `sbt test`. The important part of th
9595
[info] Suites: completed 2, aborted 0
9696
[info] Tests: succeeded 4, failed 0, canceled 0, ignored 0, pending 1
9797
[info] All tests passed.
98-
[success] Total time: 4 s, completed Jan 6, 2018 4:58:23 PM
98+
[success] Total time: 4 s
9999
````
100100

101101
A few notes about that output:

_overviews/scala-book/sbt-scalatest-tdd.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ version := "1.0"
3838
scalaVersion := "{{site.scala-version}}"
3939

4040
libraryDependencies +=
41-
"org.scalatest" %% "scalatest" % "3.0.8" % Test
41+
"org.scalatest" %% "scalatest" % "3.2.11" % Test
4242

4343
```
4444

4545
The first three lines of this file are essentially the same as the first example, and the `libraryDependencies` lines tell sbt to include the dependencies (jar files) that are needed to run ScalaTest:
4646

4747
```scala
4848
libraryDependencies +=
49-
"org.scalatest" %% "scalatest" % "3.0.8" % Test
49+
"org.scalatest" %% "scalatest" % "3.2.11" % Test
5050
```
5151

5252
>The ScalaTest documentation has always been good, and you can always find the up to date information on what those lines should look like on the [Installing ScalaTest](http://www.scalatest.org/install) page.
@@ -84,8 +84,8 @@ There isn’t much that can go wrong with that source code, but it provides a si
8484
[warn] consider launching sbt without any commands, or explicitly passing 'shell'
8585
...
8686
...
87-
[info] Compiling 1 Scala source to /Users/al/Projects/Scala/HelloScalaTest/target/scala-2.12/classes...
88-
[info] Running simpletest.Hello
87+
[info] compiling 1 Scala source to /Users/al/Projects/Scala/HelloScalaTest/target/scala-2.13/classes...
88+
[info] running simpletest.Hello
8989
Hello Alvin Alexander
9090
[success] Total time: 4 s
9191
````
@@ -107,9 +107,9 @@ Next, create a file named *HelloTests.scala* in that directory with the followin
107107
```scala
108108
package simpletest
109109

110-
import org.scalatest.FunSuite
110+
import org.scalatest.funsuite.AnyFunSuite
111111

112-
class HelloTests extends FunSuite {
112+
class HelloTests extends AnyFunSuite {
113113

114114
// test 1
115115
test("the name is set correctly in constructor") {
@@ -129,7 +129,7 @@ class HelloTests extends FunSuite {
129129

130130
This file demonstrates the ScalaTest `FunSuite` approach. A few important points:
131131

132-
- Your class should extend `FunSuite`
132+
- Your class should extend `AnyFunSuite`
133133
- You create tests as shown, by giving each `test` a unique name
134134
- At the end of each test you should call `assert` to test that a condition has been satisfied
135135

@@ -139,7 +139,7 @@ Now you can run these tests with the `sbt test` command. Skipping the first few
139139

140140
````
141141
> sbt test
142-
[info] Set current project to HelloScalaTest (in build file:/Users/al/Projects/Scala/HelloScalaTest/)
142+
[info] set current project to HelloScalaTest (in build file:/Users/al/Projects/Scala/HelloScalaTest/)
143143
[info] HelloTests:
144144
[info] - the name is set correctly in constructor
145145
[info] - a Person's name can be changed

0 commit comments

Comments
 (0)