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

前端 未结 9 1256
旧巷少年郎
旧巷少年郎 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:09

    There is difference between constructor and method marked with [TestFixtureSetUp] attribute. According to NUnit documentation:

    It is advisable that the constructor not have any side effects, since NUnit may construct the object multiple times in the course of a session.

    So if you have any expensive initialization it is better to use TestFixtureSetUp.

提交回复
热议问题