Leaf classes in the dependency graph can only be tested for state?

So, I was thinking and I came into the conclusion that when Unit-Testing, even if one wants to base mainly in behaviour-type testing (that is, with mocks, for example), I will eventually always to have to do state-based testing at least for the leaf classes (in the dependency graph).

Is this correct?

PS: I am, of course, excluding stable dependencies such as Java/C# API libraries, that one must always use.


Yes, the only way to test leaf classes in your dependency graph is to perform traditional state-based unit tests ("classical" testing in Fowler's terminology), because they have no collaborators, and therefore no hooks for your observation.

But that's a good thing: the opportunity to write state-based tests is a cause for celebration! Traditional black-box unit tests are easier to write, require less setup code, and break less often than behavioral tests that depend on implementation details.

One generally only performs behavioral testing out of necessity.

I think that's a good approach, especially if these classes are being used frequently.

Need Your Help

CSS: menu bar shifted to right in Safari

css safari

For some reason, my menu bar is shifted to right in Safari:

LINQ to SQL: How to create something like conditional include?

.net linq entity-framework include condition

I'd like to create a query contains User whose entities has Event with type == 1. I would also like the Event entries loaded into EventsCollection. My code would be something like .Include(u => u.