Hyperpragmatic pure FP testing with distage-testkit

By Pavel Shirshov

Elevator Pitch

Have you ever wanted to be more productive? We will show you how to create well-designed pure FP applications and test them effectively with previously unseen ease

Description

Having a proper test suite can turn ongoing application maintenance and development into pure joy – the best tests check meaningful properties, not the implementation details, and hold no impliict assumptions about their test environment - every test case must be self-contained and portable. To ensure that tests are free of implementation details and environment dependency, we may simply run them in a different test environment, with different implementations of components. But the boileplate and manual work involved in rewiring components, writing hardcoded fixtures and setting up different test environments make this very hard to do at scale.

To tackle this problem we’ve created distage & distage-testkit, distage-testkit gives you the following superpowers:

  • ability to easily swap out individual components or entire test environments
  • principled & leak-free control of global resources for integration testing – docker containers, DBs, DDLs
  • execute effects or allocate resources per-test, e.g. generate random fixtures per-test
  • first-class testing of functional effects
  • write tests as lambdas – access test fixtures via parameters or ZIO Environment

…and more! We’ll also discuss general testing practices and what really distinguishes good tests from great tests.

Notes

Previous version of this talk has been presented on Functional Scala 2019 and got a lot of positive feedback.