Base test classes

ScalaTest consists of lots of lightweight traits that are focused around solutions for similar or unique problems. This allows us to mix them together to solve the problem in hand.

Testing convention dictates that instead of mixing the same traits in all tests, we create a base class, which mixes all the required traits used by all the tests in the application. This gives a uniform DSL across all tests in the project. There may be cases when one particular tests need to mix a few more traits, and it's fine to do so for those individual tests.

We will be using the same principle in our example application that we wrote in previous chapters. We will create a base class that we will endeavor to reuse for all the tests. At this point, ...

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.