Removing the "integration test scam" - Understanding collaboration and contract tests
Asked Answered
N

2

9

I've recently watched Integration Tests are a Scam by J. B. Rainsberger and am now looking for more material on the subject. I have to say, I'm shocked by how much we're doing wrong, (i.e. integration testing when we should unit test), intrigued by the concepts described by Rainsberger but also confused about how to apply them. I would like to have more of the described collaboration tests and contract tests but I don't know where to start.

The only things that got stuck in my mind are the 4 questions the tests need to ask:

Side A:

Do I ask the right question?
Can I deal with the answer?

Side B:

Can I answer a question?
Do I answer correctly?

But how do I apply this to some random method in my application stack?

Is there a book or a tutorial or example out there that takes a real world example and applies these ideas of isolated micro tests? Ideally the example uses Java, C# or C++.

Any literature that deals with these concepts in general and helps me understand them better would be appreciated.

Also if there are forums out there where I can ask more detailed questions about how to go about correctly unit testing and maybe even refactoring existing code and post examples would be nice.

Thanks!

Nocti answered 14/2, 2012 at 11:50 Comment(2)
That seems like a hell of a lot of question in one single go. You might want to narrow it down. And perhaps (although others will be more able to judge this) this might be better suited for the Programmers SE?Dissatisfy
Yeah, you're right. I've limited it to the question about information resources and posted the details in the programmer section.Nocti
L
4

I would recommend xUnitTestPatterns - Refactoring Test Code by Gerald Meszaros which provides some insights into your questions and a lot of detail on good and bad of various practices when testing at the individual method level.

If you have read Refactoring by Fowler, you'll see that the answer to your questions is not necessarily black and white, but based on heuristics from your and others experience.

Lit answered 15/2, 2012 at 16:48 Comment(1)
Thanks for the tip. I got the same at the programmers SE so I've got a good feeling about ordering it. Fowler is a name I've heard a lot recently (reading "Growing object oriented software guided by tests" at the moment). Maybe I'll have to get that too.Nocti
M
2

Rainsberger over-exaggerates how inefficient integration testing is, to prove his point in reaching ultimate 100% quality (basic correctness) in code

DbC is focused on formalizing responsibilities and benefits outside of both A and B parties. Is like an extension of interface. So main focus becomes contract itself, a layer in the middle that would tell both parties if they can interact with one another.

Rainsberger clearly says that so far there is no explicit library or language support and achieve both A mocks and B inputs to ask same thing, hinting that it could be a PhD work for someone.

However Jim Weirich has a nice example where contract is a OO-pattern for testing and for both parties that agree to use it https://www.youtube.com/watch?v=7Yw744FMqTY

Mcnamee answered 25/10, 2015 at 16:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.