🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Unit Testing and TDD: all 10 questions

Quiz: Unit Testing and TDD · Question 9 of 10

Why is passing an SMS sender into a function as a parameter good for testing?

Why is passing an SMS sender into a function as a parameter good for testing?

  1. A.It makes the SMS faster
  2. B.The test can pass a mock, so no real SMS is sent and the calls can be checked
  3. C.It removes the need for asserts
  4. D.Parameters are always faster than globals
Answer & explanation

Correct answer: The test can pass a mock, so no real SMS is sent and the calls can be checked

This is dependency injection; it lets the unit be tested on its own.

Can you get the rest right without peeking?

Take the timed Quiz: Unit Testing and TDD quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →