Pada tanggal Min, 1 Mar 2020 01.11, Warren Stephens <
wsteph...@prognoshealth.com> menulis:

> I often write a function or module to handle some process that takes 3 or
> 4 steps to complete.
>
> After I am happy with the code I then proceed to write tests for the code,
> but find that I am compelled to chop the code into pieces in order to
> simplify the test code
> -- thereby losing the nice top down readability with which I started.
>
> The influence that test code has on the structure of the application code
> is highly undesirable.
>
> Test code should not exert so much influence over how the primary code is
> written.
>


In my experiences, it is a good things that the test code has influence to
the structure of application code, because if the code can not be easily
tested, there is something wrong with how I solve the problem, or maybe I
need to break it down into smaller unit and test only some parts of unit.


> The labelled *with* statements would allow for a test to be written
> specifically for each step of a function.
>
> Each test would begin at the *with* statement, providing the variables
> and values required, and end at the next *with* statement or return
> statement.
>

Now the application code are mixed with the test functionality. This is not
good design. Testing and application code are different domain, even if its
in the same repository.


> Each step of a function could be tested (or not) without having to
> refactor the function into testable pieces
> which would lose the natural structure of the original code.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMh9%2BYBgYzLW6p9bqk5gR--GjVdwviBUC7a%2BrKs-7srNfx5J9g%40mail.gmail.com.

Reply via email to