Unit Testing without Assertions

后端 未结 14 2369
夕颜
夕颜 2020-12-17 08:35

Occasionally I come accross a unit test that doesn\'t Assert anything. The particular example I came across this morning was testing that a log file got written to when a co

14条回答
  •  心在旅途
    2020-12-17 09:07

    In general, I see this occuring in integration testing, just the fact that something succeeded to completion is good enough. In this case Im cool with that.

    I guess if I saw it over and over again in unit tests I would be curious as to how useful the tests really were.

    EDIT: In the example given by the OP, there is some testable outcome (logfile result), so assuming that if no error was thrown that it worked is lazy.

提交回复
热议问题