dev
dev

Reputation: 918

How to get step timing information from SpecFlow

SpecFlow

Above image, you see red circle at 40 ms. How am i able to get that timing in step file?

Upvotes: 2

Views: 1671

Answers (2)

AlSki
AlSki

Reputation: 6961

Rajeem is correct. If you want to time a method, use a StopWatch.

The values you are seeing, both in the vs screenshot and your linked report, have values that are generated by the test *runner*s. In the case of the vs screenshot, that information is generated by either Charlie Poole's Nunit adapter https://launchpad.net/nunit-vs-adapter or the built in one for mstest. In both cases, the runner starts the stopwatch, and then starts the test framework, (e.g. Nunit) which calls into SpecFlow. However no interfaces between these parts have any mechanism for passing the timings.

Upvotes: 2

rajeemcariazo
rajeemcariazo

Reputation: 2524

You can use the Stopwatch class:

Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();

//test codes

stopwatch.Stop();
var elapsed = stopwatch.Elapsed;

Upvotes: 2

Related Questions