LearnThatStack Ace your next interview
Software Testing · question
Question 13 of 125

Explain the difference between Stubs and Drivers in Integration Testing

beginner
← All Software 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.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
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 Software Testing cheatsheet.

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

107 of 125 Software Testing answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

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