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.
NUnit 有特殊的事件监听器来响应在测试运行过程中发生的事件。MSTest 有类似的功能吗?
MSTest 具有可用于获得类似功能的属性:
一种可能让人们措手不及的行为是,这些方法的触发顺序可能不是您所期望的。由于测试以不确定的顺序运行,因此您可能会在进行类清理之前获得多个类初始化,因此您不能仅依靠类清理来隔离跨类的测试用例。在Mark Seemann 的博客上有一个很好的关于这种行为的文章。