Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MSTest" Version="4.2.3" />
<PackageReference Include="MSTest" Version="4.3.2" />
</ItemGroup>

<ItemGroup>
Expand Down
46 changes: 26 additions & 20 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2480,12 +2480,19 @@ public void StartAndroidActivityRespectsAndroidDeviceUserId ()
"The 'am start' command should contain '--user 0' when AndroidDeviceUserId is set.");
}

public enum MSTestPackageChannel
Comment thread
jonathanpeppers marked this conversation as resolved.
{
Stable,
Nightly,
}

[Test]
[TestCase ("run", AndroidRuntime.CoreCLR)]
[TestCase ("test", AndroidRuntime.CoreCLR)]
public void DotNetNewAndroidTest (string mode, AndroidRuntime runtime)
[TestCase ("run", MSTestPackageChannel.Nightly)]
[TestCase ("test", MSTestPackageChannel.Stable)]
[TestCase ("test", MSTestPackageChannel.Nightly)]
Comment on lines 2489 to +2492

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this, and it seems fine. I don't think a bug would be surfaced from the missing combination.

public void DotNetNewAndroidTest (string mode, MSTestPackageChannel msTestPackageChannel)
{
var templateName = $"DotNetNewAndroidTest_{mode}_{runtime}";
var templateName = $"DotNetNewAndroidTest_{mode}_{msTestPackageChannel}";
var projectDirectory = Path.Combine (Root, "temp", templateName);
if (Directory.Exists (projectDirectory))
Directory.Delete (projectDirectory, true);
Expand All @@ -2494,22 +2501,21 @@ public void DotNetNewAndroidTest (string mode, AndroidRuntime runtime)
var dotnet = new DotNetCLI (Path.Combine (projectDirectory, $"{templateName}.csproj"));
Assert.IsTrue (dotnet.New ("androidtest"), "`dotnet new androidtest` should succeed");

// Override the MSTest version from the template with the version used by our build
var msTestVersion = GetAssemblyMetadataValue ("MSTestPackageVersion");
var csprojPath = Path.Combine (projectDirectory, $"{templateName}.csproj");
var doc = XDocument.Load (csprojPath);
var ns = doc.Root?.Name.Namespace ?? XNamespace.None;
var msTestRef = doc.Descendants (ns + "PackageReference")
.FirstOrDefault (e => e.Attribute ("Include")?.Value == "MSTest");
Assert.IsNotNull (msTestRef, "MSTest PackageReference should exist in the generated project");
msTestRef.SetAttributeValue ("Version", msTestVersion);
doc.Save (csprojPath);

bool useMonoRuntime = runtime == AndroidRuntime.MonoVM;
var buildParameters = new List<string> {
$"UseMonoRuntime={useMonoRuntime}",
"RestoreAdditionalProjectSources=https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json",
};
var buildParameters = new List<string> ();

if (msTestPackageChannel == MSTestPackageChannel.Nightly) {
// Override the stable template version with the version used by our build.
var msTestVersion = GetAssemblyMetadataValue ("MSTestPackageVersion");
var csprojPath = Path.Combine (projectDirectory, $"{templateName}.csproj");
var doc = XDocument.Load (csprojPath);
var ns = doc.Root?.Name.Namespace ?? XNamespace.None;
var msTestRef = doc.Descendants (ns + "PackageReference")
.FirstOrDefault (e => e.Attribute ("Include")?.Value == "MSTest");
Assert.IsNotNull (msTestRef, "MSTest PackageReference should exist in the generated project");
msTestRef.SetAttributeValue ("Version", msTestVersion);
doc.Save (csprojPath);
buildParameters.Add ("RestoreAdditionalProjectSources=https://pkgs.dev.azure.com/dnceng/public/_packaging/test-tools/nuget/v3/index.json");
}

// Build and assert 0 warnings
Assert.IsTrue (dotnet.Build (parameters: buildParameters.ToArray ()), "`dotnet build` should succeed");
Expand Down
Loading