funsuite

ScalaTest 105: Adding more tests and a test suite

Problem: You want to add more unit tests and a main test suite to your ScalaTest tests.

Solution

To add more unit tests to your project, just create new test classes. For instance, to add a set of TDD-style tests for the Topping class, just create a ToppingTests class in the src/test/scala/com/acme/pizza directory:

ScalaTest 102: Writing TDD style unit tests with ScalaTest

Problem: You want to use test-driven development (TDD) style tests in your Scala applications, and need to see examples of how to write them.

Solution

Have your test classes extend the ScalaTest FunSuite, and then write your tests. Because most tests involve a setup and teardown process, you’ll usually also want to add in the BeforeAndAfter trait as well.