TestContext.WriteLine
allows additional information to be added in test reports (.trx files) in a flexible manner. This features is particularly useful to report contextual information such as details regarding Test Environments, formal parameters and so on.
[TestMethod] public void ShouldCreateUser(){ // ... Unit Test Codes.... } [TestCleanup] public void TestCleanup(){ TestContext.WriteLine("{0} : {1}", TestContext.TestName ,TestContext.CurrentTestOutcome); }
As such, above code-snippet shows the value CurrentTestOutcome
after running a test–
Hope it helps. Thanks.
Related Posts
Other posts in this series includes:
On Unit Testing:
Usage of TestContext: