question
in the article "the practice of testing the Pyramid", there is a saying:
. Do not couple the internal structure of the implementation code in your unit tests. To test observable behavior. You should think like this:
if my input is x and y, will the output be z?
even if the result is "z" (eg.) "the audit result has been saved"), how can I make sure that it is executed correctly internally?
give an example
the verification methods I can think of are as follows:
write a top-up test and verify the return data of the "get my balance" interface before and after the call to ensure that my balance has really increased.
as a result, the recharge interface and the current "get balance" result in the coupling of the test code.
once this happens, modifying the return structure of the get balance interface will face the paralysis of the whole related test code.
this is obviously inappropriate. So how exactly should the "right test" be written? To what extent can it be considered qualified?