Performance Measurement with TestContext

TestContext class is equipped with two public methods: BeginTimer and EndTimer, which allow measuring the execution time of an individual unit test. In this way, time required to execute code under test can be measured, and be recorded in reports (e.g., in associated .trx files) as follows.

TestContext.BeginTimer("longRunningProcess");
//.. invoke actual code under test
TestContext.EndTimer("longRunningProcess");

The following screenshot illustrates the report generated from running the above code.

Report Summary

To sum up, we illustrate how to use TestContext to measure execution time of code under test. Check out the next post where we show how to report additional information in test result.

Related Posts

Other posts in this series includes:

On Unit Testing:

Usage of TestContext:

Advertisement

2 thoughts on “Performance Measurement with TestContext”

  1. Hey, Indeed! It’s missing. Since this post is from long time back, I have to check if I can find it somewhere. Also, that the screenshot was merely showing the report and its format. I am not sure if it is off any importance.

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

%d bloggers like this: