in src/vstest.console/TestPlatformHelpers/TestRequestManager.cs [254:369]
public void RunTests(
TestRunRequestPayload testRunRequestPayload,
ITestHostLauncher testHostLauncher,
ITestRunEventsRegistrar testRunEventsRegistrar,
ProtocolConfig protocolConfig)
{
EqtTrace.Info("TestRequestManager.RunTests: run tests started.");
var runsettings = testRunRequestPayload.RunSettings;
if (testRunRequestPayload.TestPlatformOptions != null)
{
_telemetryOptedIn = testRunRequestPayload.TestPlatformOptions.CollectMetrics;
}
var requestData = GetRequestData(protocolConfig);
// Get sources to auto detect fx and arch for both run selected or run all scenario.
var sources = GetSources(testRunRequestPayload);
if (UpdateRunSettingsIfRequired(
runsettings,
sources,
testRunEventsRegistrar,
out string updatedRunsettings))
{
runsettings = updatedRunsettings;
}
if (InferRunSettingsHelper.AreRunSettingsCollectorsIncompatibleWithTestSettings(runsettings))
{
throw new SettingsException(
string.Format(
Resources.RunsettingsWithDCErrorMessage,
runsettings));
}
var runConfiguration = XmlRunSettingsUtilities.GetRunConfigurationNode(runsettings);
var batchSize = runConfiguration.BatchSize;
if (requestData.IsTelemetryOptedIn)
{
// Collect metrics.
CollectMetrics(requestData, runConfiguration);
// Collect commands.
LogCommandsTelemetryPoints(requestData);
// Collect data for legacy settings.
LogTelemetryForLegacySettings(requestData, runsettings);
}
// Get Fakes data collector settings.
if (!string.Equals(Environment.GetEnvironmentVariable("VSTEST_SKIP_FAKES_CONFIGURATION"), "1"))
{
// The commandline options do not have sources in design time mode,
// and so we fall back to using sources instead.
if (_commandLineOptions.Sources.Any())
{
GenerateFakesUtilities.GenerateFakesSettings(
_commandLineOptions,
_commandLineOptions.Sources.ToList(),
ref runsettings);
}
else if (sources.Any())
{
GenerateFakesUtilities.GenerateFakesSettings(
_commandLineOptions,
sources,
ref runsettings);
}
}
TestRunCriteria runCriteria = testRunRequestPayload.Sources != null && testRunRequestPayload.Sources.Any()
? new TestRunCriteria(
testRunRequestPayload.Sources,
batchSize,
testRunRequestPayload.KeepAlive,
runsettings,
_commandLineOptions.TestStatsEventTimeout,
testHostLauncher,
testRunRequestPayload.TestPlatformOptions?.TestCaseFilter,
testRunRequestPayload.TestPlatformOptions?.FilterOptions,
testRunRequestPayload.TestSessionInfo,
debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null
&& testRunRequestPayload.DebuggingEnabled)
: new TestRunCriteria(
testRunRequestPayload.TestCases,
batchSize,
testRunRequestPayload.KeepAlive,
runsettings,
_commandLineOptions.TestStatsEventTimeout,
testHostLauncher,
testRunRequestPayload.TestSessionInfo,
debugEnabledForTestSession: testRunRequestPayload.TestSessionInfo != null
&& testRunRequestPayload.DebuggingEnabled);
// Run tests.
try
{
RunTests(
requestData,
runCriteria,
testRunEventsRegistrar,
testRunRequestPayload.TestPlatformOptions);
EqtTrace.Info("TestRequestManager.RunTests: run tests completed.");
}
finally
{
_testPlatformEventSource.ExecutionRequestStop();
// Post the run complete event
_metricsPublisher.Result.PublishMetrics(
TelemetryDataConstants.TestExecutionCompleteEvent,
requestData.MetricsCollection.Metrics);
}
}