-
Notifications
You must be signed in to change notification settings - Fork 243
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. |
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: