Unit Tests and Contracts
Posted: Mon Jul 27, 2009 7:15 am
I have read the samples, documentation, and the wiki about unit test and contracts. I am glad the language supports these as first class citizens. I use unit test and asserts now in other languages.
Having the unit test and contracts in the program helps the next person who has to do maintenance (which could be me six months or a year later).
I understand (at least I believe I understand) contracts.
The question I have (trying to explain to a coworker), is the contract evaluated at compile time? Does it actually perform the action (calling the function and having the function run at compile time) and return a value to test?
The unit test is a separate compiler switch, correct? The unit test is done at runtime (just running the unit tests) and not at compile time, correct?
On the surface, it seems that a unit test and a contract are performing the same action. What is the real difference between the two?
Having the unit test and contracts in the program helps the next person who has to do maintenance (which could be me six months or a year later).
I understand (at least I believe I understand) contracts.
The question I have (trying to explain to a coworker), is the contract evaluated at compile time? Does it actually perform the action (calling the function and having the function run at compile time) and return a value to test?
The unit test is a separate compiler switch, correct? The unit test is done at runtime (just running the unit tests) and not at compile time, correct?
On the surface, it seems that a unit test and a contract are performing the same action. What is the real difference between the two?