K
K
kaxa32012021-12-01 14:58:59
PHPUnit
kaxa3201, 2021-12-01 14:58:59

Should nested methods be tested?

There is a calculate() method, inside this method the calculateAmount() method is called, in this method some calculations take place with some conditions.
So I write a unit test for the calculate() method. The question is: when testing this method, do I need to take into account the cases that are in calculateAmount() ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gordinskiy, 2021-12-01
@kaxa3201

If calculateAmount() is a public method, or another bean's method isn't, just wrap its result with whatever options you need.
If calculateAmount() is not a public method - yes, it should be taken into account.

life hack
Приватные методы не придется тестировать, если их не будет

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question