Do you use TestInitialize or the test class constructor to prepare each test? and why?

后端 未结 10 683
梦毁少年i
梦毁少年i 2020-12-02 15:35

This question regards unit testing in Visual Studio using MSTest (this is important, because of MSTest\'s execution order). Both the method marked [TestInitialize] and the t

10条回答
  •  长情又很酷
    2020-12-02 15:56

    The main advantage of using either TestInitialize() or ClassInitialize() rather than the test class instance or static constructors is its explicit nature. It clearly communicates that you are doing some setup prior to your tests. Doing this consistently should improve maintainability in the long run.

提交回复
热议问题