|
|
|
|
|
by epdlxjmonad
2265 days ago
|
|
When writing code, we often think "according to the design of our system, this condition must be true at this point of execution.” Examples are: 1. The argument x must not be 0. 2. The variable x must smaller than the variable y. 3. The list foo must be non-empty. 4. The variable x should have value 'Success' if it had value 'Try' in the beginning of the function call. These 'invariants', or assertions, can be extremely useful for testing the correctness of the code. Put simply, if an invariant is violated (during unit test, integration tests, or system tests), it indicates that either the design or the implementation is wrong. An article on testing methodology would be more appealing if it had some discussion on exploiting invariants/assertions. |
|
0 - https://en.wikipedia.org/wiki/Design_by_contract