为什么不执行TestCleanup

为什么不执行TestCleanup

本文介绍了当MSTest在TestInitialize中失败时,为什么不执行TestCleanup?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含TestInitializeTestCleanup的基类.然后,我还有从该类继承的其他测试类.当来自派生类的测试失败时,TestCleanup应该执行某些操作.

I have a base class that has a TestInitialize and a TestCleanup in it. I then have other test classes which inherit from this class. The TestCleanup is supposed to perform certain actions when a test from the derived class fails.

在实际测试中测试失败时,将执行TestCleanup.但是,当TestInitialize中的测试失败时,甚至不会执行TestCleanup.为什么会发生这种情况,有没有办法让TestCleanup被调用?

The TestCleanup gets executed when the test fails in the actual test. However, when the test fails in the TestInitialize, the TestCleanup doesn't even get executed. Why does this happen and is there a way to get the TestCleanup to get called anyway?

我不认为TestInitializeTestCleanup都在基类中这一事实完全导致了此问题,我只是想提供更多信息,以防万一.

I don't think that the fact that the TestInitialize and TestCleanup are in a base class is at all causing this issue, I just wanted to give more information just in case it was.

推荐答案

这是一个已知问题.好像已经报告给Microsoft connect.

This is a known issue. It looks like it has been reported to Microsoft connect.

http://connect.microsoft .com/VisualStudio/feedback/details/694337/testcleanup-method-does-not-run-when-it-shouldshould

这篇关于当MSTest在TestInitialize中失败时,为什么不执行TestCleanup?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 02:10