在MSTest中如何在TestCleanup中访问TestMethod异常而不在测试方法中使用try/catch块

Nag*_*aja 7 .net c# mstest stack-trace

    [TestInitialize]
    public void SetUp()
    {
    //Do required actions before every test
    }

    [TestMethod]
    public void Test1()
    {
         //Actual test
         Assert.AreEqual(1, 0);
    }

[TestCleanup]
public void TearDown()
{
//If TestMethod has failed - Get the exeception thrown by the TestMethod. So based on this I can take some action?
}
Run Code Online (Sandbox Code Playgroud)

我能够从TestContext获得TestMethod Name,Test results.但是我想在TestCleanup中获得TestMethod的堆栈跟踪.

其次,我知道实现这一目标的一种方法是在try/catch块中包装测试方法步骤,并将异常设置为变量或属性,并在拆除时对其进行处理.

但是我不想在try/catch块中包装每个testmethod.还有其他更清洁的方法吗?

因为我是MSTest和编程的新手,所以我会详细解释一些详细的解释或示例.