In the last chapter, we learned how to create a web application that uses a database. In this chapter, we will learn how to write and execute unit tests in Eclipse for JEE applications. We will cover the following topics in this chapter:
- Creating and executing unit tests using Eclipse JEE
- Executing unit tests from Eclipse IDE
- Mocking external dependencies for unit tests
- Calculating unit test coverage
Testing the software that you develop is a very important part of the overall software development cycle. There are many types of testing; each one has a specific purpose, and each one varies in scope. Some examples of testing are functional testing, integration testing, scenario testing, and unit testing.
Of all these types, unit tests are the narrowest in scope and are typically coded and executed by developers. Each unit test is meant to test a specific and small piece of functionality (typically, a method in a class), and is expected to execute without any external dependencies...