Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 997
Pete Avatar asked Feb 14 '12 11:02

Pete


People also ask

Does contract testing replace integration testing?

Firstly, contract testing does not replace integration testing. But it probably can replace some of your existing integration test scenarios, shift left, and provides faster feedback to your software development lifecycle.

What is the major problem during integration testing?

The most common problem I see with integration testing is that most attempts at integration testing do not recognize that people “using” the system have different expectations of the system, and will use the “integrations” differently depending on those expectations and their business needs.

What are the 4 approaches of integration testing?

Common approaches to integration testing. Four key strategies to execute integration testing are big-bang, top-down, bottom-up and sandwich/hybrid testing. Each approach has benefits and drawbacks. Big-bang testing: The big-bang approach involves integrating all modules at once and testing them all as one unit.

What are the advantages and disadvantages of integration tests?

Advantage – Since we can move both upwards and downwards. So, it is the most time-efficient method with the option to prioritize the modules on the top or bottom level. Disadvantage – It is difficult to implement this approach as we have integrate and move in both the directions of the module to be tested.


1 Answers

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.

like image 142
Lindsay Morsillo Avatar answered Oct 01 '22 06:10

Lindsay Morsillo