Created
March 19, 2016 10:19
-
-
Save margusmartsepp/23ec29009ad1588cf31f to your computer and use it in GitHub Desktop.
Measure NUnit test times
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly: MeasureTimeSpan] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | | |
AttributeTargets.Interface | AttributeTargets.Assembly, | |
AllowMultiple = true)] | |
public class MeasureTimeSpanAttribute : Attribute, ITestAction | |
{ | |
public ActionTargets Targets => ActionTargets.Test | ActionTargets.Suite; | |
private Stopwatch _stopwatch; | |
public void BeforeTest(ITest test) | |
{ | |
_stopwatch = Stopwatch.StartNew(); | |
} | |
public void AfterTest(ITest test) | |
{ | |
_stopwatch.Stop(); | |
Console.WriteLine(_stopwatch.Elapsed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment