Java Reference
In-Depth Information
Listing 15.1. DiscountManagerBean
DiscountManagerBean has a dependency on the MembershipLevelManager
EJB . Following the fundamental principles of writing unit tests, you'll need to mock
this dependency. Mocking ensures that you avoid any external resources that
Membership-Level-Manager may need, and mocking ensures that the focus of the
unit test is only on DiscountManagerBean . To get mocks into DiscountManager-
Bean , a constructor is provided that the unit test may use. The findDiscount()
method contains the business logic to test. You can clearly see that the output of the
method (that is, what the method returns)
depends on a couple of different inputs. The
 
Search WWH ::




Custom Search