How to unit test class with no logic?
问题 I find it easy to write unit tests for algorithms. For example, sort(List) , it is easy to write tests like: list = [2, 1, 4]; assert(sort(list) == [1, 2, 4]); But I find it really hard to test methods that have no logic, no if statements, just a set of calls. There are mainly 2 examples that I'd like an answer for how to unit test them: Example 1: Let's say I have a class that is responsible for writing some data to a file, but that data is written in a specific way by external functions (