On (20/07/16 18:05), Nikolai Kondrashov wrote:
On 07/20/2016 05:28 PM, Lukas Slebodnik wrote:
> c) if it is a hard to write unit test than it means that functions is
> complicated or do a lot of things and should be refactored. => refactored code
> will be easier to read, to understand and to test.
BTW, same goes with documentation :)
If it's hard to write, then code needs refactoring.
No,
because you can write documentation even for function which is hard to unit
test. Documentation might help to increase understanding of code.
But it does not enforce better code.
Oh, and documentation is easier to write than unit tests, we can never
write
unit tests for everything.
"easier to write" does not mean better/more readable code.
Unit test is much stricter than documentation.
BTW It does not mean that we should not use documentation comments.
We can describe "test-case" in unit test so it will be easier to
find out which use case do you want to cover with the test.
Sometimes it can be find out from the name of test.
IMHO, we should use some mixed way.
We can have a documentation for stable parts of code (e.g. sysdb)
and unit tests for other parts of code.
LS