Repository navigation
Support MSTest v4 - #157
jeremy-visionaid wants to merge 10 commits into
Conversation
Mostly check that the TestContext has been set
|
@Evangelink This is an attempt to work around microsoft/testfx#9809 in MSTest v4 using server mode in-process. It works OK for the situations that I need it to, but it's also mostly agent stuff. I was hoping you might be a better judge than me as to whether this looks roughly sane! |
There was a problem hiding this comment.
Pull request overview
Adds a new Visual Runner backend to support MSTest v4 (Microsoft Testing Platform) by hosting MSTest in-process via MTP “server mode” JSON-RPC, and wires it into the sample device test app with a new MSTest sample test project.
Changes:
- Introduces
DeviceRunners.VisualRunners.MSTestwith server-mode JSON-RPC hosting, discovery, and execution plumbing. - Adds MSTest sample tests and integrates MSTest into the sample
DeviceTestingKitApp.DeviceTestsrunner configuration. - Adds central package versions for Microsoft Testing Platform and MSTest v4 packages.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/DeviceRunners.VisualRunners.MSTest/WireTestNode.cs | Parses server-mode node updates into a typed representation (state, location, traits). |
| src/DeviceRunners.VisualRunners.MSTest/VisualTestRunnerConfigurationBuilderExtensions.cs | Adds .AddMSTest() builder extension to register MSTest discoverer/runner. |
| src/DeviceRunners.VisualRunners.MSTest/MSTestTestRunner.cs | Executes selected MSTest tests by UID and reports results back to the runner channels. |
| src/DeviceRunners.VisualRunners.MSTest/MSTestTestResultInfo.cs | Maps terminal node states into ITestResultInfo results (pass/skip/fail). |
| src/DeviceRunners.VisualRunners.MSTest/MSTestTestDiscoverer.cs | Discovers MSTest tests by running an MTP discovery session and collecting discovered action nodes. |
| src/DeviceRunners.VisualRunners.MSTest/MSTestTestCaseInfo.cs | Represents an MSTest test case and derives class/method names from node location fields. |
| src/DeviceRunners.VisualRunners.MSTest/MSTestTestAssemblyInfo.cs | Represents a test assembly and retains the runtime Assembly for platforms without Assembly.Location. |
| src/DeviceRunners.VisualRunners.MSTest/MSTestTestAssemblyConfiguration.cs | Provides an MSTest assembly configuration placeholder. |
| src/DeviceRunners.VisualRunners.MSTest/MSTestServerModeHost.cs | Implements the server-mode JSON-RPC framing/handshake and streams node update notifications. |
| src/DeviceRunners.VisualRunners.MSTest/DeviceRunners.VisualRunners.MSTest.csproj | Adds new MSTest visual runner library project and MTP/MSTest adapter dependencies. |
| sample/test/DeviceTestingKitApp.Library.MSTestTests/ViewModels/CounterViewModelTests.cs | Adds sample MSTest tests for the library view model. |
| sample/test/DeviceTestingKitApp.Library.MSTestTests/Usings.cs | Adds global MSTest using for the sample MSTest test project. |
| sample/test/DeviceTestingKitApp.Library.MSTestTests/UnitTests.cs | Adds broader MSTest sample tests (skip, failure, data-driven, cancellation token usage). |
| sample/test/DeviceTestingKitApp.Library.MSTestTests/DeviceTestingKitApp.Library.MSTestTests.csproj | Adds MSTest v4 sample test project (test attributes only; runner hosted by DeviceRunners). |
| sample/test/DeviceTestingKitApp.DeviceTests/MauiProgram.cs | Registers MSTest test assembly and enables MSTest runner in the sample app. |
| sample/test/DeviceTestingKitApp.DeviceTests/DeviceTestingKitApp.DeviceTests.csproj | References the MSTest sample test project and the MSTest visual runner project. |
| Directory.Packages.props | Adds central versions for Microsoft.Testing.Platform and MSTest v4 packages. |
| DeviceRunners.slnx | Adds the new MSTest runner project and sample MSTest test project to the solution. |
Comments suppressed due to low confidence (1)
src/DeviceRunners.VisualRunners.MSTest/MSTestServerModeHost.cs:155
- DriveSessionAsync only sends the JSON-RPC "exit" request after the operation completes normally. If ReadUntilResponseAsync throws (for example due to cancellation or a framing/parse error), the exit request is skipped, which can leave the in-process server host running and cause RunSessionAsync to hang while awaiting serverTask.
// 3. stream node updates until the request completes.
await ReadUntilResponseAsync(stream, OperationRequestId, onNode, cancellationToken);
// 4. ask the server to exit.
await SendAsync(stream, new { jsonrpc = "2.0", method = "exit" }, cancellationToken);
}
| (2, "second") | ||
| ]; | ||
|
|
||
| public TestContext TestContext { get; set; } |
|
Hey @jeremy-visionaid, I'll have a look at this next week - sorry for the delay! |
|
Thanks! I also haven't had a chance yet to see how this fits in with the work that other people have been doing (e.g. #130) and the efforts you mentioned from @jonathanpeppers. I'm already consuming this internally from a private feed and it's working OK for me. But maybe this might be useful to other people, even as an interim/throwaway thing |
|
This repo basically replaces the This is the approach I'd take if I didn't want to make changes in dotnet/sdk, and is a good way to retroactively add this to .NET 10. For .NET 11 we really only implemented MTP, because it was the new thing. |
|
Sorry @jeremy-visionaid! With vacations and some other activities, I totally forgot to have a look at this. Adding a note for Monday! |
|
Thanks for putting this together — after reviewing the approach, I think MTP server mode is reasonable for the visual-runner scenario. It is currently the supported way to receive discovery updates without executing tests. Rather than maintaining the hand-written JSON-RPC/framing implementation, I suggest trying the new You can already consume our latest builds from the public The client's existing I would recommend reworking this PR around the source client and trying the preview packages now. Ideally, DeviceRunners would then only need to launch MTP in-process and map typed test-node updates into its visual-runner abstractions, removing most of Feedback from this integration would be especially useful for validating the in-process launch API before it is finalized. |
|
Thanks for the feedback guys! @Evangelink Yup, the hand-rolled JSON and LaunchAsync parts were the bits I was really bothered by but couldn't find better ways of doing them. Glad to hear I'm not going mad... Thanks opening the ticket and for pointing me in the right direction there! Thanks also @jonathanpeppers for your review and fixing the related Android concurrent build issue too. Much appreciated! |
|
Thanks for your patience and for opening a fruitful ticket and not simply giving up or having useless rant! |
|
@Evangelink I saw Microsoft.Testing.Platform.ServerMode.Client.Sources just got released on NuGet. This looks much cleaner now, drops about 200 lines, thanks for the review! |
Evangelink
left a comment
There was a problem hiding this comment.
Two result-fidelity issues to address before merging.
Fixes: #147