In a test for a method that processes data retrieved from a database, how would you use stubbing to simulate different scenarios and edge cases related to data retrieval?

  • Stub the entire database to return predefined data
  • Stub only the network communication with the database
  • Stub the method that retrieves data, returning different values
  • Avoid stubbing and use the real database
When testing a method that processes data from a database, you should use stubbing to simulate different scenarios and edge cases related to data retrieval. This can be achieved by stubbing the method that retrieves data and having it return different values for each test scenario. Stubbing the entire database may lead to over-complicated tests, and avoiding stubbing by using the real database can result in unreliable and slow tests. Stubbing only network communication is not sufficient for simulating different scenarios related to data retrieval.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *