Join +2,660 software developers getting weekly tips covering security, quality and system design.
Can you recognise which one is the real Jack Sparrow and which is a... double? 🤫 - "Bartosz! You were supposed to teach me about coding! 😳" - "Reader, this IS about coding... Continue reading." Ok. So what does this have to do with testing? A lot When you want to write a unit test, you want to test a single unit of behavior of your application in an isolated manner. The key here is isolation, because you want your unit test to be fast and independent from other tests. The graphic below presents a unit test of a service class that collaborates with another class to produce some result, but it's isolated from the repository class... with a TEST DOUBLE. When running unit tests, you don't want to establish connections to any external dependencies, especially a database (there are other tests, like integration or e2e tests, for such cases). Dependency on a database would ruin the performance of your unit tests and entangle the results with some external state. We can divide test doubles into two high-level groups
Ok... That's all for today. Pills are supposed to be short. 😁 But... remember that unit testing is a really broad topic with a lot of surprising and complex parts. 🙄 Rate this email: All the best, |
Join +2,660 software developers getting weekly tips covering security, quality and system design.