Chapter 5. Testing

 

This chapter covers

  • Configuring your build to use specs2
  • Learning how to run JUnit tests
  • Incorporating external libraries and code into your testing
  • Using the ScalaCheck library to improve your testing experience
  • Incorporating Selenium HTML tests using the ScalaTest Selenium DSL

In the previous chapters, you set up your preowned-kittens project and learned about the default build. Obviously, you’re quality conscious, so you want to do as much testing as possible. In this chapter you’ll learn how to use the power and interactivity of sbt to make the development and testing cycle a pleasant experience. You’re also eclectic in your choice of testing frameworks, so we’ll show you how to set up four: specs2, ScalaCheck, JUnit, and ScalaTest. Each has its strengths and weaknesses; thus you can use each of these frameworks for testing different aspects of the project. We’ll show you how to configure each framework separately.

You also want to demonstrate to potential customers that you’ll take good care of their kittens and that they can trust you. How can you show this? Well, you’ll include on your site a report of the tests that you’ve run as part of the development cycle. This will help persuade potential clients. To generate the reports, you’ll have to fork your tests to run them in a different JVM from sbt. Because there isn’t a built-in solution for reporting with JUnit, you’ll incorporate our custom code into the build to get the reports you want.

5.1. Configuring specs2 with sbt

5.2. JUnit and using custom code

5.3. ScalaCheck

5.4. Integration testing

5.5. Summary

sitemap