I do agree that this test can be seen as being fragile, but this example is just a simple one that we can use to explain the concept of dependency injection and mocking. In a real-life scenario, I'd have used an interface instead to decouple the code so that we could switch out the implementation further down the line. I didn't want to throw too much at the readers at once though and scare them away haha :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Marcin, thanks for the comment.
I do agree that this test can be seen as being fragile, but this example is just a simple one that we can use to explain the concept of dependency injection and mocking. In a real-life scenario, I'd have used an interface instead to decouple the code so that we could switch out the implementation further down the line. I didn't want to throw too much at the readers at once though and scare them away haha :)