-
Notifications
You must be signed in to change notification settings - Fork 262
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
Allow xunit, nunit and other frameworks to run with the new runner #2164
Comments
Maybe I am missing something, but why not? Currently, it feels like if Entity Framework only supported MSSQL and is asking do you want support for eg MySQL? |
Big thumbs-up here for XUnit support - this is going to be necessary to start porting large chunks of the dotnet/* repositories onto this new runner. |
@baronfel We just need to provide enough new nice features for you to want to migrate to MSTest 😉 |
Would be very useful to support xunit for us and many customers - it would save a lot on wasted CPU cycles in CI/CD |
Would love to see if it can give a similar boost to nunit tests |
+1 for XUnit |
+1 NUnit |
Totally agree! The migration from xUnit to MSTest wasn't a hard job. There are just some nice-to-have features in xUnit that save some code lines. |
I'm in the process of writing my own framework currently. So is the new runner locked down to just MSTest at the present time? I'd definitely like to make use of the new runner, especially with things like performance improvements over VSTest. |
It is advertised only as MSTest runner but the code is open to any custom framework. The only issues for non-MSTest framework at the moment are:
For this last point, if your project is OSS I can definitely help you and you can already start getting some inspiration from there draft PRs I have open: |
Thanks @Evangelink ! Those PRs are very helpful. Question, they both seem to be a VS bridge (which makes sense if we're trying to keep backwards compatibility.) Since my framework is still a WIP, I don't care much about this. So, is there a non-bridged mode? If so I guess I'll have to wait for documentation, as I'd have to rewrite the VSTest stuff that scans assemblies and generates test cases. And if there is a non-bridged mode, does that, or will it, come with support for dotnet test and test explorer? I assume it would because these are quite core to the testing experience currently, but those PRs had comments that those features were only made available by that bridging package. Thanks! |
Yes there is a non-bridged mode, this is actually the default but to move the masses (MSTest, xUnit and NUnit) we had to bring this compat layer :)
We will craft a dummy sample (tomorrow) that show how to create and plug a custom framework and how to return some state. This can be easily done and would be useful for when we build the technical doc.
Yes definitely! The support of |
Amazing! Thanks for the prompt replies and look forward to any coming samples and docs! From what I could see when navigating the code base, this looks like a very welcome improvement. From recently creating a VSTest adapter, the code felt very legacy and convoluted, and very temperamental around "FullyQualifiedName"s or specific Glad to see there's a push for a better testing experience! |
Dear .NET community, thank you all for your interest and feedback on our new platform! I'll move forward by closing this ticket and invite you to track the respective test framework tickets:
|
Can I ask where to look for the samples for a non-bridged runner when they're out? The samples folder in this repository? |
@thomhurst I am adding an example that is doing the minimum amount of work to "run a test" here: #2446 There is test framework implementation, and a project using it. In reality the framework would come from a nuget package, and that nuget package would probably generate program.cs via build targets. All the details of how to actually discover or run a test are up to your implementation. :) I've commented on the parts that did not seem clear, let me know if (ideally in a new issue), if there are more explanations needed. We will eventually document all that api, and add more examples. |
@nohwnd If I'm reading the code correctly, it seems like the bridge that's being replaced here is just the translation of old ObjectModel types into the new types. How about for developers who want to control the console output when being run via |
Thanks @nohwnd I've got my runner working! (With dotnet run, and manually hooking it up. I can't get it to automatically hook up with the msbuild package) My next thing id like to ask is how to get test filters, like how VSTest can filter on properties, but I'll raise an issue for that |
Yes. And it's needed only when you run in "runner mode"(self-contained) and you don't want to change the "current" VSTest adapter implementation. So it's done for a smooth/quick/co-existence onboarding but it's not mandatory. Pay attention that when you run in "runner mode" you cannot use anymore VSTest extensions like VSTest loggers, datacollectors, in-process datacollectors. The new platform implements a completely different extensibility points and expose a protocol for "remote" interaction (like IDEs VS/VSCode).
The "output device" is abstracted in the new platform. So it's possible plug a completely custom UX. By default we provide a "console" one. The extension point at the moment is "internal" because we're following the "hardening" principle. We will open when we're "good" with the design and all the expected usage. So we can "easily" support the "dotnet run" output customization. For the "dotnet test" is a bit more tricky.
Another tricky part are the parameters. Historically the SDK(dotnet test) supports "only" the VSTest platform with fixed options. The new platform is extensible in it and so we cannot anymore have a "fixed" set of options. For this reason as explained in the guide above you have to pass the new custom options(they depends on extensions added) using an MSBuild property Anyway this is the first version. We're planning to make it "first citizen" for the SDK and so move back to
As explained above the new platform allows custom options so it can accommodate your scenario. Here what we support https://github.com/microsoft/testfx/blob/main/test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineTests.cs and here the parser https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs |
@thomhurst ideally the platform should not define "how to filter tests" because the adapters could express it in different way. The new platform introduces the concept of "test node with attached properties" so your tests could be a tree where every node is not related to a "method". Anyway you can implement "your custom" filtering system for your tests and expose it with an custom option. |
@nohwnd @Evangelink as part of this new runner architecture, have you considered having tests be a first-class thing in conjunction with the hosting model of For one, I'd love to be able to configure OpenTelemetry on some of our testing projects to track down and optimize execution times, push test-specific telemetry information to Datadog, etc. However, the entire test framework architecture today is a "walled garden" that doesn't integrate with anything that other "normal" projects do. If there is an issue tracking that, please let me know. Otherwise, assuming you'd agree this makes sense, I can open an issue myself documenting the request. |
@julealgon I'd say it depends how far you are seeing things. Here is the technical doc of the new platform: https://github.com/microsoft/testfx/blob/main/docs/testingplatform/Index.md In this folder https://github.com/microsoft/testfx/blob/main/samples/public/TestingPlatformExamples/ you will have some guided examples. Looking at Program.cs you can see that the platform can be extended. As for different hosting capabilities, it's technically possible and we already have a few but we don't yet have anything open-telemetry based. OTel is definitely an essential addition we would like to provide but it's hard to make the progresses we want (too few people and too many things to handle). We don't have a public ticket for what we want to do with OTel but I have found this #1680 one that could maybe overlap with some of your requirements. |
Ok, I really like the way that is shaping up, thanks for sharing @Evangelink . It would be perfect if it was made to work on top of all the I see it is doing some of that API shape, but kind of just replicating it, in a sense, in a custom fashion. If this was ever adapted to work on top of the hosting model, adding open telemetry support would become trivial as one could just tap into the existing |
We had a long look at ASP.NET for the design and on the first prototype we really reused all principles but we realized some cases were either more specific in "web" wolrd or in "testing" world. As for the explanation of not directly depending on the package, one of the most common issues with VSTest is that there was always a problem with the deps it has (newtonsoft, nuget framework...) where either the version was conflicting with the one wanted by user (and the deps is not declared as package deps but is force copied to the output - breaking user execution), some update issue or this was preventing some scenario to happen because one of the deps was not allowing it. This might not seem super intuitive but this is the reality of what has been observed through VSTest life. I would need to make some experiment but I'm wondering if we could have some extension that would allow this bridging. |
One suggestion I'd share @Evangelink is precisely what the OpenTelemetry team did: they have this "raw" version of OTEL, called the SDK, that is basically dependency-free as well, and relies on some static calls and instantiations etc. Then, they have the This basically allows for completely dependency-free use cases by using only the SDK directly, or the full integration mode for consumers that can opt for that using the hosting extensions. Something like this seems like it would fit your constraints well, from what you described there. |
@julealgon Thanks for the pointer! I will check that out (probably next week). |
Summary
MSTest runner is a new lightweight runner for MSTest tests. Please vote below if you'd like the same experience for other frameworks. And optionally share why, and which framework, please.
https://devblogs.microsoft.com/dotnet/introducing-ms-test-runner
The text was updated successfully, but these errors were encountered: