Answer the question
In order to leave comments, you need to log in
How to implement TestResult check in unit tests?
Good time to all readers!
My question is about test automation: how can I implement a TestResult check after the test method completes?
For example, there is a code:
[TestClass]
public class Class1
{
[TestMethod]
public void Method 1()
{
MethodA();
MethodB();
Method C();
}
[TestCleanup]
public void AfterTest();
{
MethodA();
MethodB();
}
}
Answer the question
In order to leave comments, you need to log in
Found a solution using the TestContext.CurrentTestOutcome property.
[TestClass]
public class UnitTest
{
private TestContext TestContext { get; set; }
[TestCleanup]
public void TestCleanup()
{
if (TestContext.CurrentTestOutcome == UnitTestOutcome.Passed)
//do something
}
[TestMethod]
public void TestMethod()
{
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question