DEV Community

Discussion on: The TDD Test

 
phlash profile image
Phil Ashby

"Unit tests are a solution for languages that do not provide contracts. In this sense contracts are the prerequisites, postconditions, and invariants of the methods and classes. That's entirely different from contracts at the scope of system requirements, external contracts, and quality standards."

OK, I get this - and I found this presentation on contracts within the language for C++20: cppeurope.com/wp-content/uploads/2...

I contest however that these internal correctness contracts /must/ be derived from the external contracts defining expected behaviour or they are useless in proving that the right thing is being constructed, indeed Mr Garcia in the linked paper says as much on slide 20 "Correctness -> Degree to which a software component matches its specification." - scaffolding that helps build a bungalow when a block of flats was required is not very helpful :)

Thread Thread
 
eljayadobe profile image
Eljay-Adobe • Edited

Unit tests cannot fulfill the role of acceptance tests.

To further elaborate...

Unit tests they are useless in proving that the right thing is being constructed. They only demonstrate basic correctness.

Unit tests won't show whether a bungalow is correct, or a block of flats is correct.

They'll show if the nail is correct. The nail does not care if it is used in a bungalow, or a block of flats.