Project Layout

Learn the settings and tasks to run tests on an sbt application.

The main focuses of this course are testing and leveraging various Scala testing libraries effectively. To avoid unnecessary complexity, we’ll keep the code under test as simple as possible. This lesson introduces our running example, a very simplified model of the Educative platform, and shows the structure of our sbt project.

Running example

Our running example will be a very simplified model of the Educative platform. It features many courses, each of which has an author, one or more tags, one or more lessons, and a price. Along the way, we’ll make this example more complex and test several aspects of the classes involved in it. For now we’ll use the following model in Scala 3:

Press + to interact
case class Author(firstName: String, lastName: String)
case class Lesson(title: String)
case class Course(
title: String,
author: Author,
price: BigDecimal,
lessons: Seq[Lesson],
tags: Seq[String]
)
case class Educative(courses: Seq[Course])

Common sbt tasks for testing

Since this course is all about testing, in this section, we’ll look at the most common sbt tasks and settings for testing. We should add testing dependencies (such as ScalaTest, ScalaCheck, and others we’ll get to know during this course) only to the test configuration to avoid their inclusion in the main sources. The location of test classes inside our project will vary depending on whether they’re ...