When do I use the TestFixtureSetUp attribute instead of a default constructor?

前端 未结 9 1107
旧巷少年郎
旧巷少年郎 2021-01-30 15:59

The NUnit documentation doesn\'t tell me when to use a method with a TestFixtureSetup and when to do the setup in the constructor.

public class MyTe         


        
9条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 16:12

    I have often wondered what the need for [TestFixtureSetUp] was, given that there is a simple, well understood first class language construct that does exactly the same thing.

    My preference is to use constructors, to take advantage of the readonly keyword ensuring member variables cannot be reinitialised.

提交回复
热议问题