Posted By:
Robert_Lybarger
Posted On:
Wednesday, May 16, 2007 08:56 AM
As far as test design goes, there are as many opinions as developers. If you want to make sure that "place order" works as expected, writing a unit test specifically for that is good. But the other tests will run independently of that test (plus or minus whatever happens in setup(), maybe). So if you then want to test the "enquire order" functionality, have that method first place an order and then include the unit test logic for the enquiry part. After all, you already have a unit test for placing the order in another method ... you can assume that the supporting business works as intended when you unit-test some other capability. Also feel free to use method names
without the word "test" in them to hide them from the jUnit engine. For example:
public void testPlaceOrder() {
doPlaceOrder(arg values here);
// checks and assertions here for that order placement
}
public void testEnquireOrder() {
doPlaceOrder(arg values here);
// logic here to enquire
// checks and assertions here for that enquiry
}
private void doPlaceOrder(parameter list here) {
// logic to place an order here
}