Repository navigation
[androidtest] Support dotnet test --list-tests - #13531
Draft
jonathanpeppers wants to merge 5 commits into
Draft
jonathanpeppers wants to merge 5 commits into
jonathanpeppers wants to merge 5 commits into
Conversation
The host adapter (Microsoft.Android.Run) ignored DiscoverTestExecutionRequest, so --list-tests reported 0 tests (exit code 8). It now runs 'am instrument -e list-tests true' and publishes discovered tests. On device, MTP does not send discovery results to user IDataConsumers, so the androidtest template now hosts MSTest in-process with MtpServerClient (Microsoft.Testing.Platform.ServerMode.Client.Sources) and streams discovered tests and results back with the instrumentation streaming protocol. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Move this from the androidtest template into the SDK defaults, so test apps do not get CS1574 from the MTP server-mode client source package. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove the discovered-count result and its check, merge the test state mapping into one switch, and read the TRX path directly from the run result artifacts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In a
dotnet new androidtestproject,dotnet test --list-testsreports 0 tests and exits with code 8. There are two causes:AndroidTestAdapterinMicrosoft.Android.Runhandles onlyRunTestExecutionRequestand ignoresDiscoverTestExecutionRequest.IDataConsumers.TestHostBuilderskips building them whenIsForDiscoveryRequestis true. This is still true in MTP 3.0 previews.Changes:
AndroidTestAdapterhandlesDiscoverTestExecutionRequest. It runsam instrument -e list-tests true, then publishes eachevent=discoveredstatus as a discovered test node.TestInstrumentation.cshosts MSTest in-process withMtpServerClient.LaunchInProcessAsync. The client comes from the source-only packageMicrosoft.Testing.Platform.ServerMode.Client.Sources, whose docs name embedded Android/iOS test runners as a use. The template callsDiscoverTestsAsyncorRunTestsAsyncand streamsdiscovered/start/finishstatuses with the existing instrumentation protocol. Discovery and runs use the same test UIDs.GenerateDocumentationFilenow defaults tofalsewhenEnableMSTestRunner=true. Without this, a broken XML doccrefin the client package source gives warning CS1574 in every test app.Existing projects keep working: their instrumentation does not send
eventstatuses, so the host still uses the TRX fallback. To get--list-tests, they must updateTestInstrumentation.csand add the package reference.Tests:
StreamingTestscases: discovery with--list-tests, and the TRX fallback that the previous template uses.DotNetNewAndroidTestcase:list.Tested:
Microsoft.Android.Run.dll, on a newandroidtestproject:dotnet test --list-testsin Debug and Release: 3 tests discovered.dotnet test --report-trx: 1 passed, 1 failed (with message and stack trace), 1 skipped, and a TRX file.dotnet run: the same counts inINSTRUMENTATION_RESULT.StreamingTestson Windows: 6/6 passed. These tests use a Unix shell fakeadband are skipped on Windows, so I ran them with a temporary.cmdfakeadb, which is not committed.DotNetNewAndroidTest. These depend on CI. TheGenerateDocumentationFilechange also depends on CI, because my device tests used the installed SDK.