-
Notifications
You must be signed in to change notification settings - Fork 574
[templates] Update androidtest to MSTest 4.3.2 #12052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jonathanpeppers
merged 1 commit into
main
from
jonathanpeppers-update-androidtest-mstest
Jul 13, 2026
+27
−21
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2480,12 +2480,19 @@ public void StartAndroidActivityRespectsAndroidDeviceUserId () | |
| "The 'am start' command should contain '--user 0' when AndroidDeviceUserId is set."); | ||
| } | ||
|
|
||
| public enum MSTestPackageChannel | ||
| { | ||
| 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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
@@ -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"); | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.