Test fixtures
Test fixture is a collection of classes, other libraries, and artifacts. These can be files, sockets, database connections, and so on, that are required for testing. Clean code principles dictate that we reuse these fixtures across tests and make them as abstract as possible. For example, if two tests require speaking to a database, then it would be obvious to reuse the same database connection code for both. It is important to try and avoid duplicating the fixture code across those tests. The more code duplication you have in your tests, the greater drag the tests will have on refactoring the actual.
These are the recommended techniques for reusing the code in ScalaTest:
- Refactor using Scala
- Override
withFixture
- Mixin a
before-and-after ...
Get Scala Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.