Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一个一次性设置方法,在所有测试装置中只调用一次。
这是为了设置常见的东西,比如 AutoMapper,所有东西都使用的一些模拟。
我怎样才能做到这一点?(而且我不是在谈论 TestFixtureSetup)
您可以让所有测试类都继承自一个基测试类,并在构造函数中进行设置。
public class TestBase { public TestBase() { // Global setup } } public class MyTest : TestBase { // Tests }