Skip to content

Commit

Permalink
Fix GivenDotnetTestBuildsAndRunsTestFromCsproj tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Nov 23, 2024
1 parent 582359a commit 7a83a59
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public GivenDotnetTestBuildsAndRunsTestFromCsproj(ITestOutputHelper log) : base(
[Fact]
public void MSTestSingleTFM()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("3");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

// Call test
CommandResult result = new DotnetTestCommand(Log, disableNewOutput: true)
Expand Down Expand Up @@ -160,7 +160,7 @@ public void GivenAFailingTestItDisplaysFailureDetails()
public void ItAcceptsMultipleLoggersAsCliArguments()
{
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("10");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);
var trxFileNamePattern = "custom*.trx";
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "RD");

Expand Down Expand Up @@ -197,7 +197,7 @@ public void ItAcceptsMultipleLoggersAsCliArguments()
public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
{
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("5");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);
string configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug";
string expectedError = Path.Combine(testProjectDirectory, "bin",
configuration, ToolsetInfo.CurrentTargetFramework, "VSTestCore.dll");
Expand Down Expand Up @@ -225,7 +225,7 @@ public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
public void TestWillCreateTrxLoggerInTheSpecifiedResultsDirectoryBySwitch()
{
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("6");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TR", "x.y");

Expand Down Expand Up @@ -256,7 +256,7 @@ public void TestWillCreateTrxLoggerInTheSpecifiedResultsDirectoryBySwitch()
public void ItCreatesTrxReportInTheSpecifiedResultsDirectoryByArgs()
{
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("7");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);
var trxFileNamePattern = "custom*.trx";
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "RD");

Expand Down Expand Up @@ -342,7 +342,7 @@ public void ItBuildsAndTestsAppWhenRestoringToSpecificDirectory()
public void ItUsesVerbosityPassedToDefineVerbosityOfConsoleLoggerOfTheTests(string verbosity, bool shouldShowPassedTests)
{
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp($"9_{verbosity}");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([verbosity, shouldShowPassedTests]);

// Call test
CommandResult result = new DotnetTestCommand(Log, disableNewOutput: true)
Expand Down Expand Up @@ -414,7 +414,7 @@ public void ItTestsWithTheSpecifiedRuntimeOption()
public void ItAcceptsNoLogoAsCliArguments()
{
// Copy and restore VSTestCore project in output directory of project dotnet-vstest.Tests
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("14");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

// Call test with logger enable
CommandResult result = new DotnetTestCommand(Log, disableNewOutput: true)
Expand All @@ -434,7 +434,7 @@ public void ItAcceptsNoLogoAsCliArguments()
[PlatformSpecificFact(TestPlatforms.Windows)]
public void ItCreatesCoverageFileWhenCodeCoverageEnabledByRunsettings()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("11");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

string resultsDirectory = Path.Combine(testProjectDirectory, "RD");

Expand Down Expand Up @@ -475,7 +475,7 @@ public void ItCreatesCoverageFileWhenCodeCoverageEnabledByRunsettings()
[PlatformSpecificFact(TestPlatforms.Windows | TestPlatforms.OSX | TestPlatforms.Linux)]
public void ItCreatesCoverageFileInResultsDirectory()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("12");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

string resultsDirectory = Path.Combine(testProjectDirectory, "RD");

Expand Down Expand Up @@ -511,7 +511,7 @@ public void ItCreatesCoverageFileInResultsDirectory()
[PlatformSpecificFact(TestPlatforms.Windows | TestPlatforms.OSX | TestPlatforms.Linux)]
public void ItCreatesCoberturaFileProvidedByCommandInResultsDirectory()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("15");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

string resultsDirectory = Path.Combine(testProjectDirectory, "RD");

Expand Down Expand Up @@ -547,7 +547,7 @@ public void ItCreatesCoberturaFileProvidedByCommandInResultsDirectory()
[PlatformSpecificFact(TestPlatforms.Windows)]
public void ItHandlesMultipleCollectCommandInResultsDirectory()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("16");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

string resultsDirectory = Path.Combine(testProjectDirectory, "RD");

Expand Down Expand Up @@ -588,7 +588,7 @@ public void ItHandlesMultipleCollectCommandInResultsDirectory()
[PlatformSpecificFact(TestPlatforms.FreeBSD)]
public void ItShouldShowWarningMessageOnCollectCodeCoverage()
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp("13");
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([]);

// Call test
CommandResult result = new DotnetTestCommand(Log, disableNewOutput: true)
Expand Down Expand Up @@ -714,7 +714,7 @@ public void FilterPropertyCorrectlyHandlesComma(string filter, string folderSuff
[InlineData("--results-directory")]
public void EnsureOutputPathEscaped(string flag)
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp(flag);
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([flag]);

var pathWithComma = Path.Combine(AppContext.BaseDirectory, "a,b");

Expand Down Expand Up @@ -763,7 +763,7 @@ public void PathEndsWithSlashOrBackslash(string flag, string slashesOrBackslashe
{
// NOTE: We also want to test with forward slashes because on Windows they
// are converted to backslashes and so need to be handled correctly.
string testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp(Guid.NewGuid().ToString());
string testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([flag, slashesOrBackslashes]);
string flagDirectory = Path.Combine(testProjectDirectory, "flag-dir");

// Call test
Expand All @@ -788,7 +788,7 @@ public void PathEndsWithSlashOrBackslash(string flag, string slashesOrBackslashe
[InlineData("-e:foo=barexe")]
public void ArgumentsEndWithDllOrExeShouldNotFail(string arg)
{
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp();
var testProjectDirectory = CopyAndRestoreVSTestDotNetCoreTestApp([arg]);

// Call test
CommandResult result = new DotnetTestCommand(Log, disableNewOutput: true)
Expand All @@ -804,12 +804,12 @@ public void ArgumentsEndWithDllOrExeShouldNotFail(string arg)
}
}

private string CopyAndRestoreVSTestDotNetCoreTestApp([CallerMemberName] string callingMethod = "")
private string CopyAndRestoreVSTestDotNetCoreTestApp(object[] parameters, [CallerMemberName] string callingMethod = "")
{
// Copy VSTestCore project in output directory of project dotnet-vstest.Tests
string testAppName = "VSTestCore";

var testInstance = _testAssetsManager.CopyTestAsset(testAppName, callingMethod: callingMethod)
var testInstance = _testAssetsManager.CopyTestAsset(testAppName, callingMethod: callingMethod, identifier: string.Join(",", parameters.Select(p => p.ToString())))
.WithSource()
.WithVersionVariables();

Expand Down

0 comments on commit 7a83a59

Please sign in to comment.