Dummy modules that simulate lower-level components
Called by the module being tested (downward calls)
Used in top-down integration testing
Provide controlled responses to test upper-level logic
Drivers:
Dummy modules that simulate higher-level components
Call the module being tested (upward calls)
Used in bottom-up integration testing
Initiate test scenarios and validate responses
Example Implementation:
// Stub example for top-down testing
public class PaymentServiceStub {
public PaymentResult processPayment(PaymentRequest request) {
// Return controlled test response
return new PaymentResult("SUCCESS", "TXN-123");
}
}
// Driver example for bottom-up testing
public class OrderServiceDriver {
public void testInventoryService() {
InventoryService service = new InventoryService();
boolean result = service.checkAvailability("PRODUCT-123", 5);
assert result == true;
}
}
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.