3 ms·
> But in C# for example, if the system was not designed with dependency injection and everything being an interface it's very hard to build a test harness since
by bmm6o 5y ago
> But in C# for example, if the system was not designed with dependency injection and everything being an interface it's very hard to build a test harness since you can't mock anything. Which means everything has to be tested manually.
I wouldn't have put it like that, but I think I know what you mean. Mocks for unit testing do require that you have defined an interface to implement, which means that every class that you want to be mocked out needs to have an interface extracted. It is extra work. Overall I think the tradeoff is worth it, myself, especially if your IDE can automated extracting an interface. But it is dumb work that a smarter language/type system could avoid.
- magicalhippo 5y ago> [...] which means that every class that you want to be mocked out needs to have an interface extracted. It is extra work. If you define the interface first, then you can simply copy-paste that into the class definition and off you go implementing it. Hardly any more work at all.