Java test class with many private methods

前端 未结 4 579
终归单人心
终归单人心 2021-01-11 17:42

I have a class that has the responsibility of importing contracts from a CSV to database.

The class itself has only one public method that starts the import and the

4条回答
  •  抹茶落季
    2021-01-11 18:25

    Some people argue that you should only test your API (i.e. your public methods).

    A possible solution is to use package private so that only classes in the same package can access those methods.

    Personally, I wouldn't test private methods, I would focus on the public methods behaving as expected. If you feel your private methods carry too much weight, then perhaps they do and you should separate further the functionality.

提交回复
热议问题