Skip to content

Commit 20b2f10

Browse files
authored
Simplfy NuGet cache folder handling in integration tests (#7573)
1 parent 0a4877f commit 20b2f10

121 files changed

Lines changed: 176 additions & 182 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AbortionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public async Task AbortWithCTRLPlusC_CancellingTests(string tfm)
3636
testHostResult.AssertOutputMatchesRegex("Canceling the test session.*");
3737
}
3838

39-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
39+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
4040
{
4141
private const string Sources = """
4242
#file AbortMSTestAsset.csproj

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AnalyzersTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public void TestMethod()
5656
using TestAsset testAsset = await TestAsset.GenerateAssetAsync("TestForMSTEST0001", code);
5757
DotnetMuxerResult result = await DotnetCli.RunAsync(
5858
$"build {testAsset.TargetAssetPath}",
59-
AcceptanceFixture.NuGetGlobalPackagesFolder.Path,
6059
warnAsError: false,
6160
cancellationToken: TestContext.CancellationToken);
6261
if (isAdapterReferenced)
@@ -113,7 +112,6 @@ public void TestMethod()
113112
using TestAsset testAsset = await TestAsset.GenerateAssetAsync("AnalyzersMetapackage", code);
114113
DotnetMuxerResult result = await DotnetCli.RunAsync(
115114
$"build {testAsset.TargetAssetPath}",
116-
AcceptanceFixture.NuGetGlobalPackagesFolder.Path,
117115
warnAsError: false,
118116
cancellationToken: TestContext.CancellationToken);
119117
result.AssertOutputContains("MSTEST0014");
@@ -153,7 +151,6 @@ public void TestMethod()
153151
using TestAsset testAsset = await TestAsset.GenerateAssetAsync("AnalyzersTestFrameworkPackage", code);
154152
DotnetMuxerResult result = await DotnetCli.RunAsync(
155153
$"build {testAsset.TargetAssetPath}",
156-
AcceptanceFixture.NuGetGlobalPackagesFolder.Path,
157154
warnAsError: false,
158155
cancellationToken: TestContext.CancellationToken);
159156
result.AssertOutputContains("MSTEST0014");
@@ -196,7 +193,6 @@ public void TestMethod()
196193
using TestAsset testAsset = await TestAsset.GenerateAssetAsync("Analyzers", code);
197194
DotnetMuxerResult result = await DotnetCli.RunAsync(
198195
$"build {testAsset.TargetAssetPath}",
199-
AcceptanceFixture.NuGetGlobalPackagesFolder.Path,
200196
environmentVariables: new()
201197
{
202198
["DOTNET_CLI_UI_LANGUAGE"] = "it-IT",
@@ -295,7 +291,7 @@ public async void TestMethod1()
295291

296292
private static async Task AssertAnalysisModeAsync(string mode, string[] contains, string[] doesNotContain, string targetAssetPath)
297293
{
298-
async Task<DotnetMuxerResult> BuildTaskAsync() => await DotnetCli.RunAsync($"build {targetAssetPath}", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, warnAsError: false);
294+
async Task<DotnetMuxerResult> BuildTaskAsync() => await DotnetCli.RunAsync($"build {targetAssetPath}", warnAsError: false);
299295

300296
string output;
301297
if (mode is "Recommended" or "All")

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AppDomainTests.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public async Task RunTests_With_VSTest(bool? disableAppDomain)
2626
null => string.Empty,
2727
};
2828

29-
DotnetMuxerResult compilationResult = await DotnetCli.RunAsync($"test -c Release --no-build {AssetFixture.TargetAssetPath}{disableAppDomainCommand}", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, workingDirectory: AssetFixture.TargetAssetPath, cancellationToken: TestContext.CancellationToken);
29+
DotnetMuxerResult compilationResult = await DotnetCli.RunAsync($"test -c Release --no-build {AssetFixture.TargetAssetPath}{disableAppDomainCommand}", workingDirectory: AssetFixture.TargetAssetPath, cancellationToken: TestContext.CancellationToken);
3030
Assert.AreEqual(0, compilationResult.ExitCode);
3131

3232
compilationResult.AssertOutputContains(@"Passed! - Failed: 0, Passed: 2, Skipped: 0, Total: 2");
@@ -45,7 +45,7 @@ public async Task DiscoverTests_With_VSTest(bool? disableAppDomain)
4545
null => string.Empty,
4646
};
4747

48-
DotnetMuxerResult compilationResult = await DotnetCli.RunAsync($"test -c Release --no-build {AssetFixture.TargetAssetPath} --list-tests{disableAppDomainCommand}", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, workingDirectory: AssetFixture.TargetAssetPath, cancellationToken: TestContext.CancellationToken);
48+
DotnetMuxerResult compilationResult = await DotnetCli.RunAsync($"test -c Release --no-build {AssetFixture.TargetAssetPath} --list-tests{disableAppDomainCommand}", workingDirectory: AssetFixture.TargetAssetPath, cancellationToken: TestContext.CancellationToken);
4949
Assert.AreEqual(0, compilationResult.ExitCode);
5050
}
5151

@@ -107,7 +107,7 @@ private static string GetTestDllPath(string assetPath, string targetFramework) =
107107

108108
public TestContext TestContext { get; set; }
109109

110-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
110+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
111111
{
112112
private const string SingleTestSourceCode = """
113113
#file AppDomainTests.csproj
@@ -125,6 +125,10 @@ we end up with a -dev or -ci version which will lose resolution over -preview de
125125
<UseVSTest>true</UseVSTest>
126126
</PropertyGroup>
127127
128+
<ItemGroup>
129+
<PackageDownload Include="Microsoft.TestPlatform" Version="[$MicrosoftNETTestSdkVersion$]" />
130+
</ItemGroup>
131+
128132
</Project>
129133
130134
#file global.json
@@ -177,6 +181,7 @@ public static IEnumerable<int> GetData()
177181
public override (string ID, string Name, string Code) GetAssetsToGenerate() => (AssetName, AssetName,
178182
SingleTestSourceCode
179183
.PatchCodeWithReplace("$TargetFramework$", TargetFrameworks.NetFramework[0])
180-
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion));
184+
.PatchCodeWithReplace("$MSTestVersion$", MSTestVersion)
185+
.PatchCodeWithReplace("$MicrosoftNETTestSdkVersion$", MicrosoftNETTestSdkVersion));
181186
}
182187
}

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AspireSdkTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public async Task EnableAspireProperty_WhenUsingVSTest_AllowsToRunAspireTests()
2828
: testHost.FullName + ".dll";
2929
DotnetMuxerResult dotnetTestResult = await DotnetCli.RunAsync(
3030
$"test {exeOrDllName}",
31-
AcceptanceFixture.NuGetGlobalPackagesFolder.Path,
3231
workingDirectory: AssetFixture.AspireProjectPath,
3332
warnAsError: false,
3433
suppressPreviewDotNetMessage: false,
@@ -39,7 +38,7 @@ public async Task EnableAspireProperty_WhenUsingVSTest_AllowsToRunAspireTests()
3938
dotnetTestResult.AssertOutputContains("Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1");
4039
}
4140

42-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
41+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
4342
{
4443
public const string AspireProjectName = "AspireProject";
4544

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AssemblyCleanupTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In AsmCleanup
2626
""");
2727
}
2828

29-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
29+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
3030
{
3131
public const string ProjectName = "AssemblyCleanupTests";
3232

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AssemblyResolutionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void Dispose()
6868
public async Task InitializeAsync(CancellationToken cancellationToken)
6969
{
7070
VSSolution solution = CreateTestAsset();
71-
DotnetMuxerResult result = await DotnetCli.RunAsync($"build {solution.SolutionFile} -c Release", AcceptanceFixture.NuGetGlobalPackagesFolder.Path, cancellationToken: cancellationToken);
71+
DotnetMuxerResult result = await DotnetCli.RunAsync($"build {solution.SolutionFile} -c Release", cancellationToken: cancellationToken);
7272
result.AssertExitCodeIs(0);
7373

7474
TestHost = TestHost.LocateFrom(solution.Projects.Skip(1).Single().FolderPath, TestProjectName, TargetFramework);

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/AssemblyResolverTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task RunningTests_DoesNotHitResourceRecursionIssueAndDoesNotCrashTh
2424
testHostResult.AssertExitCodeIs(ExitCodes.Success);
2525
}
2626

27-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
27+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
2828
{
2929
public string TargetAssetPath => GetAssetPath(AssetName);
3030

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/CancellationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public async Task WhenCancelingTestContextTokenInTestMethod_MessageIsAsExpected(
128128
testHostResult.AssertOutputContains("Failed!");
129129
}
130130

131-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
131+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
132132
{
133133
public const string ProjectName = "TestCancellation";
134134

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ConfigurationMSTestSettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task TestConfigJson_AndRunSettingsHasMstest_Throws(string tfm)
2424
testHostResult.AssertStandardErrorContains("Both '.runsettings' and '.testconfig.json' files have been detected. Please select only one of these test configuration files.");
2525
}
2626

27-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
27+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
2828
{
2929
public const string ProjectNameWithMSTestRunSettings = "ConfigurationMSTestSettings";
3030

test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ConfigurationMSTestV2SettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public async Task TestConfigJson_AndRunSettingsHasMstestv2_Throws(string tfm)
2424
testHostResult.AssertStandardErrorContains("Both '.runsettings' and '.testconfig.json' files have been detected. Please select only one of these test configuration files.");
2525
}
2626

27-
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
27+
public sealed class TestAssetFixture() : TestAssetFixtureBase()
2828
{
2929
public const string ProjectNameWithMSTestV2RunSettings = "ConfigurationMSTestV2Settings";
3030

0 commit comments

Comments
 (0)