Java Reference
In-Depth Information
used by your application may become very complex. As such, unlike unit tests that should
remain in the projects containing the code the unit tests cover, integration tests are best put
into their own project. Maven dependency injection can get all the code that needs to be in-
tegration tested, and continuous build tools like Bamboo or Jenkins ensure the integration
tests get run. Although integration testing is a big step, it still can't cover all scenarios. The
final level of testing is functional testing.
We didn't cover functional testing in this chapter except to mention it as a level of an ef-
fective testing strategy. Functional testing typically falls on a team of individuals whose job
is to use the application and verify that it's working properly. At this level, your application
is fully deployed to some testing environment that hopefully closely matches a production
environment. Unit testing can tell you if the business rules are all working properly, and in-
tegration testing can tell you if the pieces of the application are integrating properly. Func-
tional testing is the last line of defense for logical problems with your application. Unit
and integration tests may all pass without any technical issues, but that doesn't necessarily
mean that what the tests are checking is correct. For example, for the ActionBazaar auction
application, it may have been decided at some point to give gold members an 80% dis-
count. All unit and integration tests can verify that the application is doing this correctly,
but (hopefully) the functional testing done by members of the testing team will look at the
result and raise a concern.
Testing will never be 100% accurate, but combining all three of these testing strategies ef-
fectively will result in a well-performing application. This is all we're going to cover on
testing of EJBs. Let's review what you've learned.
15.6. Summary
This chapter has been a brief introduction to testing EJBs. The first topic we covered was
the different types of testing strategies, specifically unit testing, integration testing, and
functional testing. We defined unit testing as a testing strategy designed to exercise the ap-
plication's business logic by feeding it different input and examining the output to assert
that the results are correct. It does this by concentrating tests on one class at a time and
using a mocking tool such as Mockito to mock any dependencies to return responses ap-
propriate for the test. Unit tests should be quick and easy to run with little or no setup and
no access to external resources.
Search WWH ::




Custom Search