← 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?
- A.MySQL is too slow for any program
- B.Constructors cannot create objects
- C.Tests cannot call constructors
- 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 →