This project uses ScalaTest
to write all the unit tests in the course.
- You must have
git
installed - You must have Java v13 installed
➜ java -version
openjdk version "13" 2019-09-17
OpenJDK Runtime Environment AdoptOpenJDK (build 13+33)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13+33, mixed mode, sharing)
- You must have sbt 1.3.3 or higher installed
➜ sbt --version
sbt version in this project: 1.3.3
sbt script version: 1.3.3
- You must have Scala 2.13.1 installed
➜ scala --version
Scala code runner version 2.13.1 -- Copyright 2002-2019, LAMP/EPFL and Lightbend, Inc.
- Create a fork of this repo. Follow Github documentation on how to achieve this.
- Clone your forked repo.
git clone https://github.com/<your-user-name>/Unit-Testing-In-Scala
cd Unit-Testing-In-Scala
sbt "runMain BankOfScala"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.1.0" % "test"
- Download the ScalaTest jar file. This is available on Quickstart page
- Download the scala-xml jar file
- Compile the Test class
scalac -classpath "*.jar" HelloWorldSpec.scala
- Run the Test
scala -classpath "*.jar" org.scalatest.run HelloWorldSpec
The latest ScalaMock release 4.4.0
has not been updated with the latest ScalaTest release 3.1.0
.
There is an open pull request to merge the changes.
However, there are no breaking or conflicting changes between ScalaTest and ScalaMock.
So, in order to learn ScalaMock, you can learn it with the ScalaTest release 3.0.8
which is 1 release behind the latest ScalaTest 3.1.0
.
Clone the repository
https://github.com/hhimanshu/Unit-Testing-In-Scala-Mocking
The test source is available under src/test/scala
.
To run all the tests, run
test
To run the test including a specific tag, run
testOnly -- -n com.h2.tags.Fast
testOnly -- -n com.h2.tags.Slow
To run the test excluding a specific tag, run
testOnly -- -l com.h2.tags.Fast
testOnly -- -l com.h2.tags.Slow