Where do you accept mocking - immediate addictions, or do you grow boundaries ...?

So, I'm fairly new to both unit testing and mocking in C # and .NET; I am using xUnit.net and Rhino Mocks respectively. I am a converter and I am focused on writing behavior characteristics, I guess, instead of being purely TDD. Ba, semantics; I want the automatic safety system to work above, essentially.

A thought struck me. I get programming from interfaces, and the benefits of breaking dependencies. Sold. However, in my set of behavior tests (aka unit tests ;-)), I assert the behavior of one interface at a time. As is the case, one implementation of the interface at a time, with all its dependencies, jaded and expected settings.

The approach seems to be that if we check that the class behaves as it should from its collagen dependencies and in turn relies on each of these dependent dependencies to sign the same quality contract , we are golden. Seems reasonable.

Let's get back to thought. Is there any meaning in semi-integration tests where the test armature asserts against a unit of concrete implementations that are related to each other and we test its internal behavior against mocking dependencies? I just re-read it and I think I might have phrased it better. Obviously there will be a certain amount of "okay, if it adds value to you, keep doing it" I suppose - but has anyone else thought of this and got the benefits outweighing the costs?

0


source to share


2 answers


Your question has been debated for years and can also be rephrased as "what is a unit"?

There is no law of unit testing that says you need to test each class separately. However, to be maintainable, your tests only really need to change when the behavior they are experiencing changes. Having looked at this, it is often wise to use specific versions of close associates and fakes for more distant ones.



The only place I absolutely use fakes of one type or another is to follow Michael Per's Unit Testing Rules .

0


source


I don't see any value in integration tests that simply bundle fully testable inner classes together.



It seems to me that the meaning in integration tests is where it relates to the platform or frontends, i.e. contracts you cannot unit test.

0


source







All Articles