Why in unit testing tests should not depend on the order of execution?

前端 未结 2 1349
北恋
北恋 2021-01-26 17:07

It is a very often opinion that unit testing should not rely on tests order. I think it is not an exact rule but recommendation.

But in some cases it does not look good.

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-26 17:43

    Because unit tests are meant to test individual units of work in isolation. Cutility method calls in CSoket should be mocked in unit tests for CSoket. This way, the unit tests for CSoket become independent of CUtility tests passing or failing. Then, it no longer matters if CUtility or CSoket tests are run first.

提交回复
热议问题