More of Test Doubles

 

The blog post I selected is “Understanding Test Doubles - Fakes, Stubs, Mocks, and Spies” by Sarah Dutkiewicz. I chose this resource because it gives our view of how we do test doubles with better examples for class as it explains several kinds of test doubles and shows how each one supports more focused and maintainable tests through concrete code examples. The article explains that “test doubles” is an umbrella term for objects that replace real dependencies during testing, and that not all doubles should be used in the same way. The post explains that fakes are simple working implementations made for testing, stubs return pre-programmed responses, mocks are used to verify that certain interactions happened, and spies record calls so the test can inspect them later. It continues to uses small C# examples with interfaces like IUserRepository and IExternalService to show when each type is appropriate and why choosing the right one matters. It also emphasizes that using the wrong kind of test double can make tests harder to understand and maintain.

             I selected this article because I needed another view of test doubles from the other source to better understand the concept more than I learned from class. Even though we did this in class while trying to write with on live, it was still difficult to clearly understand when to use each one. Seeing the concepts explained again with different examples helped me connect the definitions to real situations in code. It showed me that choosing the correct test double depends on the goal of the test, not just the definition of the term as it seems like the words and definitions from examples from class was making it harder for me to understand the concept. Also using stubs make it easier to test the functions of the code as they are used when you only need to control the output of a method. However, it also made me realize that if I overuse the methods, especially mocks, it will complicate the test more than needed especially when the goal of the test is to check the output. In the future, I expect to apply this by thinking more carefully about whether I need to verify interactions or simply control behavior, which will help me write cleaner and more maintainable test cases as I can double check if the workflow is working while in the middle of writing new lines of code.

 

https://blog.nimblepros.com/blogs/understanding-test-doubles/

Comments

Popular posts from this blog

Waterfall 2.0

Is Agile going to fail?

Docker and it basics