Open matheusgontijo opened 9 months ago
Hi @matheusgontijo, hope you're doing well. It's pretty hard to make a concrete out of this, but I'll do my best. There are certainly some things I have to share about this.
write
call. This is an example of interface simplification by focusing on the consumer needs.I hope this helps :) and thank you for your kind words regarding the original post. I'm glad to see it keeps on being relevant.
Thank you so much for your thoughts as well as for quick reply @frankdejonge. No enough words to thank you đđđ
@frankdejonge thank you so much for your great content as well as for sharing with the community đđđ Greatly appreciated! đđđ
I have a few questions about your testing approach without mocks. I would be more than happy if you could find some time to help me clarify them, if that's possible by any chance.
đđ 1 - Let's say that we are building an e-commerce project, for example. Usually applications like that have lots of layers to be tested, in contrast to libraries.
Let's say that all
MyCustomServiceXXX
classes don't touch external resources, like database/http/filesystem and etc... The only external hit is fromMyCustomRepositoryInterface
. That means I need to passMyCustomRepositoryInterface
with a concrete fake implementationMyCustomRepositoryFAKE
all the way down fromMyCustomService001
untilMyCustomService006
?I mean, that way my test is going to touch all classes
MyCustomService001
untilMyCustomService006
, correct?đđ 2 - If yes, then I would need to create aaaaaalllll dependencies manually, correct? Kinda of perform my own dependency injection for each test. For many layers, this work seems take a good amount of work... doesn't it? Especially during refactoring.
Is not there a tricky DI manager strategy to make it easier to several layers? It would be super helpful, in case you know any to share with us đđđ
đđ 3 - This once was sold me like a black-box strategy, but I was thinking to other day... this approach is actually white-box! Is not it or I'm out of my mind?
Reason: you need to know very well the implementation to make sure you create fake "ports/adapters". Also, if somebody in my team refactors the
MyCustomService006
to use another two repositories, then one needs to also refactor my test... So, our test is coupled to the internal implementation... is it correct to assert that or I'm missing something?Once again, thank you so much for your time and greatly appreciate your work đđđ