3 ms·
I often found that these terms are not very usefull when explaining the concepts of IoC in testing (which is essentially what they do) to colleagues who were un
by cessor 10y ago
I often found that these terms are not very usefull when explaining the concepts of IoC in testing (which is essentially what they do) to colleagues who were unfamiliar with it. Programming in .NET I usually tried to use frameworks that avoided the terms, such as NSubstitute where you create an object by substitution:
var format = Substitute.For<IFormatCode>();
I haven't used it in a while but I remember that Rhino Mocks asked for ridiculous code like
var format = MockRepository.GenerateStub<IFormatCode>();
(Which one is it, a Mock or a Stub? And: Does it matter?)
I recommend Gerard Meszaros excellent book XUnit Test Patterns, he makes more fine grained distinctions between different aspects of testing. I liked his notion that you simply create objects that produce or react to "indirect input and output" (i.e. exceptions, opcodes, sideeffects) rather than "direct input and output" (which is what "arrange" and "assert" are checking). Mocks and stubs are only realizations of different patterns.
http://xunitpatterns.com/ http://xunitpatterns.com/
- freshhawk 10y agoThat's an outstanding book. I'm not a Java programmer and that still might be the best book on testing, how to design tests, what to test and how think about testing at a high level that I've read.