Hi i would like to log the test failed message , I know its possible to check the status in
TearDown
Using the following
TestContext.CurrentContext.Result.Status.ToString();
Is possible to get the reason for test fail in TearDown . Some thing like the following
Expected: True
But was: False
at NUnit.Framework.Assert.That(Object actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.IsTrue(Boolean condition)
at Test.FileSystemTests.QuoteFiles() in ExampleTests.cs: line 57
If
TestContext.CurrentContext.Result
does not contain the values you are looking for, you can also try
TestExecutionContext.CurrentContext.CurrentResult
This worked for me with NUnit 3.0 in the TearDown as well as other methods.
Hi am not sure you got the solution for this issue. But here is my answer for this. Using Nunit 3.0 you can achieve this with below lines...
TestContext.CurrentContext.Result.Outcome.Status; (For test Execution Status)
TestContext.CurrentContext.Result.StackTrace; (For Stack Trace Message)
TestContext.CurrentContext.Result.Message; (For Test Result Message)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With