←back to thread

Unit tests as documentation

(www.thecoder.cafe)
94 points thunderbong | 5 comments | | HN request time: 0s | source
1. mihaigalos ◴[] No.41872231[source]
In TDD, u-tests are called "spec". Pretty much sums it up.
replies(2): >>41872337 #>>41872778 #
2. lucianbr ◴[] No.41872337[source]
So again, any inputs outside of those exemplified in unit tests are unspecified behaviour? How would this work for mathematical operators for example?
replies(2): >>41872555 #>>41875288 #
3. viraptor ◴[] No.41872555[source]
A part of this lives in the spec name, and a part in the assumption that the Devs are not psychos. As in, if you test that sum(a,b) returns a sum of your numbers, the name/description of the test says so. And the second part means that it should hold for all numbers and the exceptions would be tested explicitly - nobody added "if a=5 & b=3 return 'foobar'" to it.
4. advisedwang ◴[] No.41872778[source]
spec and documentation are things different though?
5. samatman ◴[] No.41875288[source]
Induction is a valid form of inference.