Output additional information in Test Reports with TestContext

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.

public void ShouldCreateUser(){
// ... Unit Test Codes....

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:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: