-
Notifications
You must be signed in to change notification settings - Fork 315
/
ExecutionPerfTests.cs
80 lines (71 loc) · 3.21 KB
/
ExecutionPerfTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.TestPlatform.PerformanceTests.PerfInstrumentation;
using Microsoft.VisualStudio.TestPlatform.Common.Telemetry;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Microsoft.TestPlatform.PerformanceTests.TranslationLayer;
[TestClass]
public class ExecutionPerfTests : TelemetryPerfTestBase
{
[TestMethod]
[TestCategory("TelemetryPerf")]
[DataRow("MSTest1Passing", 1)]
[DataRow("MSTest100Passing", 100)]
[DataRow("MSTest1000Passing", 1000)]
[DataRow("MSTest10kPassing", 10_000)]
[DataRow("NUnit1Passing", 1)]
[DataRow("NUnit100Passing", 100)]
[DataRow("NUnit1000Passing", 1000)]
[DataRow("NUnit10kPassing", 10_000)]
[DataRow("XUnit1Passing", 1)]
[DataRow("XUnit100Passing", 100)]
[DataRow("XUnit1000Passing", 1000)]
[DataRow("XUnit10kPassing", 10_000)]
public void RunTests(string projectName, double expectedNumberOfTests)
{
var runEventHandler = new RunEventHandler();
TestPlatformOptions options = new() { CollectMetrics = true };
var perfAnalyzer = new PerfAnalyzer();
using (perfAnalyzer.Start())
{
var vstestConsoleWrapper = GetVsTestConsoleWrapper(traceLevel: System.Diagnostics.TraceLevel.Off);
vstestConsoleWrapper.RunTests(GetPerfAssetFullPath(projectName), GetDefaultRunSettings(), options, runEventHandler);
vstestConsoleWrapper.EndSession();
}
Assert.AreEqual(expectedNumberOfTests, runEventHandler.Metrics[TelemetryDataConstants.TotalTestsRun]);
PostTelemetry(runEventHandler.Metrics, perfAnalyzer, projectName);
}
[TestMethod]
[TestCategory("TelemetryPerf")]
[DataRow("MSTest1Passing", 1)]
[DataRow("MSTest100Passing", 100)]
[DataRow("MSTest1000Passing", 1000)]
[DataRow("MSTest10kPassing", 10_000)]
[DataRow("NUnit1Passing", 1)]
[DataRow("NUnit100Passing", 100)]
[DataRow("NUnit1000Passing", 1000)]
[DataRow("NUnit10kPassing", 10_000)]
[DataRow("XUnit1Passing", 1)]
[DataRow("XUnit100Passing", 100)]
[DataRow("XUnit1000Passing", 1000)]
[DataRow("XUnit10kPassing", 10_000)]
public void RunTestsWithDefaultAdaptersSkipped(string projectName, double expectedNumberOfTests)
{
var runEventHandler = new RunEventHandler();
TestPlatformOptions options = new()
{
CollectMetrics = true,
SkipDefaultAdapters = true, // <-- skipping adapters
};
var perfAnalyzer = new PerfAnalyzer();
using (perfAnalyzer.Start())
{
var vstestConsoleWrapper = GetVsTestConsoleWrapper(traceLevel: System.Diagnostics.TraceLevel.Off);
vstestConsoleWrapper.RunTests(GetPerfAssetFullPath(projectName), GetDefaultRunSettings(), options, runEventHandler);
vstestConsoleWrapper.EndSession();
}
Assert.AreEqual(expectedNumberOfTests, runEventHandler.Metrics[TelemetryDataConstants.TotalTestsRun]);
PostTelemetry(runEventHandler.Metrics, perfAnalyzer, projectName);
}
}