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

Quiz: SOLID Principles · Question 9 of 10

Why does OrderService that creates new MySQLDatabase() inside itself make testing hard?

Why does OrderService that creates new MySQLDatabase() inside itself make testing hard?

  1. A.MySQL is too slow for any program
  2. B.Constructors cannot create objects
  3. C.Tests cannot call constructors
  4. D.The service is tied to a real database, so a fake store cannot be passed in for a test
Answer & explanation

Correct answer: The service is tied to a real database, so a fake store cannot be passed in for a test

Injecting an abstraction lets tests use a FakeStore with no database.

Can you get the rest right without peeking?

Take the timed Quiz: SOLID Principles quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →