🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Unit Testing and TDD: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What are the three parts of a well-structured unit test?
  2. Q2. What does this print? (code)
  3. Q3. In TDD, what must happen in the "red" step?
  4. Q4. What does this print? (code)
  5. Q5. What is the difference between a stub and a mock?
  6. Q6. According to the test pyramid, which tests should a project have the MOST of?
  7. Q7. A function has 100% statement coverage. What can you conclude?
  8. Q8. A unit test passes on the developer's laptop but fails on the CI server at midnight because it uses today's date. Which FIRST property does…
  9. Q9. Why is passing an SMS sender into a function as a parameter good for testing?
  10. Q10. A change turns = into and an existing test for the exact boundary now fails. What kind of bug did the test catch?