LearnThatStack Ace your next interview
Integration Testing · question
Q.03 of 20

Explain the difference between Stubs and Drivers in Integration Testing

beginner
← All Integration Testing questions
Re-explain

Stubs:

  • 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.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Integration Testing cheatsheet.

← Back to all Integration Testing questions
Pro · $10/mo

17 of 20 Integration Testing answers are gated.

Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.

  • Full answers + code
  • AI explain - simpler, deeper, or visualized
  • 1,000 AI credits / month
  • Cancel anytime