If you're developing application using the code contracts, you may know, that this concept was introduced in Eiffel
programming language.
I have become very confused after trying this concept in my C# application using System.Diagnostics.Contracts
.
The main question for me is the next:
Are unit-tests really needed, if you have code contracts?
One of the major differences, that unit-test frameworks usually don't provide, is the possibility to call private methods (except MS fakes
library with its shims
). It's done, because of supporting composition & the idea, that private methods are covered by public method calls.
As for the code contracts, I can declare Contract.Requires
, Contract.Ensures
for private methods.
So, why do I need unit-testing, when I have code-contracts, which behavior is very similar.
Thanks