Skip to content

Commit b3d524c

Browse files
Update logic of mixed mode of dotnet test (vstest and mtp)
1 parent 5ba2b11 commit b3d524c

15 files changed

+97
-38
lines changed

src/Cli/dotnet/commands/dotnet-test/LocalizableStrings.resx

+3-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ For MSTest before 2.2.4, the timeout is used for all testcases.</value>
317317
<comment>{0} - test message state</comment>
318318
</data>
319319
<data name="CmdUnsupportedVSTestTestApplicationsDescription" xml:space="preserve">
320-
<value>Test project '{0}' is using VSTest. When opting-in via dotnet.config, all the test projects are expected to be using Microsoft.Testing.Platform.
320+
<value>When opting-in via dotnet.config, all test projects are expected to be using Microsoft.Testing.Platform.
321+
The following test projects are using VSTest:
322+
{0}
321323
See https://aka.ms/dotnet-test/mtp for more information.</value>
322324
</data>
323325
<data name="Aborted" xml:space="preserve">

src/Cli/dotnet/commands/dotnet-test/MSBuildHandler.cs

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
54
using System.Collections.Concurrent;
6-
using System.IO;
75
using Microsoft.DotNet.Tools.Common;
86
using Microsoft.DotNet.Tools.Test;
97
using Microsoft.Testing.Platform.OutputDevice;
@@ -91,6 +89,22 @@ private int RunBuild(string filePath, bool isSolution, BuildOptions buildOptions
9189

9290
private void InitializeTestApplications(IEnumerable<TestModule> modules)
9391
{
92+
// If one test app has IsTestingPlatformApplication set to false (VSTest and not MTP), then we will not run any of the test apps
93+
IEnumerable<TestModule> vsTestTestProjects = modules.Where(module => !module.IsTestingPlatformApplication);
94+
95+
if (vsTestTestProjects.Any())
96+
{
97+
_areTestingPlatformApplications = false;
98+
99+
_output.WriteMessage(
100+
string.Format(
101+
LocalizableStrings.CmdUnsupportedVSTestTestApplicationsDescription,
102+
string.Join(Environment.NewLine, vsTestTestProjects.Select(module => Path.GetFileName(module.ProjectFullPath)))),
103+
new SystemConsoleColor { ConsoleColor = ConsoleColor.Red });
104+
105+
return;
106+
}
107+
94108
foreach (TestModule module in modules)
95109
{
96110
if (!module.IsTestProject && !module.IsTestingPlatformApplication)
@@ -99,15 +113,6 @@ private void InitializeTestApplications(IEnumerable<TestModule> modules)
99113
throw new InvalidOperationException();
100114
}
101115

102-
if (!module.IsTestingPlatformApplication)
103-
{
104-
// If one test app has IsTestingPlatformApplication set to false (VSTest and not MTP), then we will not run any of the test apps
105-
// Note that we still continue the loop here so that we print all projects that are VSTest and not MTP.
106-
_areTestingPlatformApplications = false;
107-
_output.WriteMessage(string.Format(LocalizableStrings.CmdUnsupportedVSTestTestApplicationsDescription, Path.GetFileName(module.ProjectFullPath)), new SystemConsoleColor { ConsoleColor = ConsoleColor.Red });
108-
continue;
109-
}
110-
111116
var testApp = new TestApplication(module, _args);
112117
_testApplications.Add(testApp);
113118
}

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.cs.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.de.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.es.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.fr.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.it.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ja.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ko.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pl.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.pt-BR.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.ru.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.tr.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hans.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Cli/dotnet/commands/dotnet-test/xlf/LocalizableStrings.zh-Hant.xlf

+6-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)