Chapter 9. Testing your application
This chapter covers
- Roo test creation commands
- Stubbing tests
- Mocking entities and collaborators
- Web-based testing challenges
- Testing with Selenium
Spring Roo helps you build your applications rapidly, but that doesn’t mean you should skimp on your testing plans. Chances are, you’re building the applications so fast that it would help to slow down a bit and write some useful tests. The more you test up front, the fewer surprises you’ll find in production.
You’ve already learned that simple actions, such as using the --test-Automatically flag to create entities, help ensure you have a baseline of entity persistence tests for your application. But you can do more. As you saw in chapters 3 and 4, you can write your own tests, even reusing the DataOnDemand classes to create both persistent and transient versions of your entities. You can also write integration tests for your Spring beans and install Selenium for end-to-end testing.
In this chapter, you’ll see how Roo makes it easy to set up your test environments and how you can test using Roo’s integration and web testing technologies, such as the Spring test runner and Selenium.
A web-based application can be tested at several levels using isolated, method-level unit tests; more sophisticated, in-container integration tests; and live, externally executed website tests. Roo supports all three levels of testing, as shown in figure 9.1.