Scala Testing, Mocking and Property based testing

Duration: 2 days

Rest assured that this course will cover all relevant bases to make sure you have all the necessary skills to work with key Scala Test frameworks:

  • ScalaTest
  • ScalaMock
  • ScalaCheck

In order to get the best from this course it is highly recommended that students should be at least familiar with the basics of the Scala Programming language. (Ideally their knowledge of Scala should reach the level established by our Core Scala Course).

Please find the course objectives below:

Introduction

  • Recap of automatic software testing
  • Testing styles
  • Discuss popular Testing Frameworks for Scala

ScalaTest

  • Overview of ScalaTest
  • Testing styles (FunSuite, WordSpec, FlatSpec, FunSpec, …)
  • Using Given-when-then
  • Running tests (using sbt, maven, junit, …)
  • Writing assertions
  • Using the Matcher DSL
  • Writing fixtures

Scala Mock

  • Introduction to Scalamock
  • Discuss different mocking techniques (function, proxy and macro)
  • Integrate with ScalaTest and Specs2
  • Discuss and use expectation-first (mocking)
  • Discuss and use record-then-verify (stubbing)
  • using argument matchers
  • expect method/function calls
  • mocking behaviour by returning values

ScalaCheck

  • Introduce property based testing
  • Introduce scalacheck
  • Introduce the architecture (key types)
  • Running and integrating with other test frameworks
  • Defining generators
  • Configuration (thresholds, number of workers etc)
  • Add reporting
  • Discuss various property based patterns
  • Discuss extensions (e.g, usinh shapeless)
For an onsite course please contact us