FAQs Data: 03: ScalaTest using IntelliJ IDEA IDE

This extends FAQs Data: 01: Getting started with Spark Scala on IntelliJ IDEA.

Step 1: Note the relevant test libraries in the pom.xml file.

ScalaTest on IntelliJ IDEA

ScalaTest on IntelliJ IDEA

scalatest-maven-plugin is used to run the tests & scalatest_* & specs2-* dependencies are added as shown below.

Step 2: Create a very simple “Calculator” class with two methods – multiply(..) & divide(…). Create the class in a new package “myapp” under “src/main/scala”

JUnit Style

ScalaTest Unit Testing Style

ScalaTest FunSpec BDD Style

Behaviour Driven Development (BDD) style of testing.

ScalaTest FlatSpec BDD Style

Behaviour Driven Development (BDD) style of testing.

There are more Specs like AnyFreeSpec, AnyFeatureSpec & AnyPropSpec.

Which style?

ScalaTest supports different styles of testing, each designed to address a particular set of needs. Refer to ScalaTest styles. It is recommended to use AnyFlatSpec style as the default choice, because it is flat, and familiar to most developers, but guides you into writing focused tests with descriptive, specification-style names.


300+ Java & Big Data Interview FAQs

16+ Java Key Areas Interview Q&As

800+ Java Interview Q&As

300+ Java & Big Data Tutorials