MsTest - executing method before each test in an assembly

后端 未结 5 1477
青春惊慌失措
青春惊慌失措 2021-02-06 21:45

Is it possible to run specific method before each test in an assembly?

I know about TestInitialize attribute but this attribute has \"class scope\". If it\'

5条回答
  •  滥情空心
    2021-02-06 22:19

    Well isn't MSTest instantiating the class for each test? That was my understanding of it. In such a case whatever you call from your constructor is the initialization code (per test by definition).

    EDIT: If it doesn't work (which I still think it should because MSTest needs to make sure that individual test method runs are isolated) then TestInitialize is your attribute. By the way the best unit-test comparison is available at Link on Codeplex

提交回复
热议问题