Re:Write tests. Not too many. Mostly integration (2017)
by usrusr on Friday February 01, 2019 @09:33AM
(#19054341)
When the result of the function under test is nontrivial, but JSONable, I make it literally a recording: set your favorite JSON tool to pretty print and compare the output to the expectation in a string literal or file. Any change will be easy to inspect, diff viewers are great. The expected counterpart may or may not start out to be manually authored. After changes, it's usually much easier to inspect the diff and copy the approved version or edit a copy of partially correct output.
[ Parent
| on HN ]
Re:Write tests. Not too many. Mostly integration (2017)
by donjoe on Friday February 01, 2019 @09:46AM
(#19054450)
Yes, I do exactly the same to make sure the output stays the same. Snapshotting is awesome (for go, cupaloy works quite well [1] - jest for react is great) but does not give me the chance to 'record' the underlying logic dynamics. That's why I think unit tests are still an important tool at hand.