TestContext class is equipped with two public methods:
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.
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.
Other posts in this series includes:
On Unit Testing:
Usage of TestContext: