3 ms·
I like how 'code examples' are above 'test cases' ... But a test case would include a code example, and proof that it works. -sigh-
by wccrawford 15y ago
I like how 'code examples' are above 'test cases' ... But a test case would include a code example, and proof that it works. -sigh-
- angdis 15y agoI think code examples are something that are best included in the "getting started" section of documentation. It gives the user a quick, usable, concise illustration of how to perform the most basic tasks. Sometimes that's all you need and this is frequently omitted by some software documentation. Test cases are certainly useful if you need to dive into comprehensive/advanced usage of the API. But if you just want to "get started", a huge vat of unit tests can be daunting.
- gigamonkey 15y agoBut would a test case be a good example of using the code? As in, good for the purpose of understanding the code.
- chc 15y agoTechnically, all the code in your program could rightly be called a "code example." But it's not very good for determining how to use the code in your program. Test cases are closer to being good code examples, but they're still generally optimized for checking correctness rather than illustrating use. If nothing else, a good, complete set of test cases will be full of distracting noise.