-
Notifications
You must be signed in to change notification settings - Fork 80
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
xUnit Parallel Settings Not Being Respected By Test Runner in Visual Studio 2019 #191
Comments
I'm having this issue too. With two different test assemblies that fight for the database and one end up with a deadlock. |
Is this issue has been fixed already? I'm having same issue to with regards to this. |
It's not as far as I'm aware. |
Any progress on this? It's a bit unfortunate. |
Just to add to this. I've been reading about how tests in the same class run in serial, but after splitting tests that I want to run in parallel I still didn't see difference in times. So I decided to remove Visual Studio from the equation. Approximate test time in Visual Studio: 30 seconds. I do have one test that takes 12-14 seconds to run which I need to fix, but this does show that parallel is not respective in Visual Studio because that specific test is the runtime of all my tests. |
They don't care about Visual Studio or supporting any of its features. Never ever recommend using xUnit. |
Installing this package allows everything to run in parallel: |
Same here - I use I have two Xunit test projects which I want to run sequentially (for better understanding like merging the tests from both projects in your mind then running the merge sequentially). So I followed the instructions and added a xunit.runner.json in both projects following the instructions here: And used this file (xunit.runner.json) in each project {
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"parallelizeAssembly": false,
"parallelizeTestCollections": false
} Copied it to build folder in each project: <ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup> A test from project So the settings in the files |
@HypeillingerChillinger We have no control over when VSTest chooses to run two assemblies in parallel, because it isn't leaving that decision to us. In order for us to have control, it would have to run a single instance of our test adapter, and pass us both assemblies and say "run both". Instead, what it does is instantiate us twice, and tells each instance "go run this one assembly". So the setting is ignored, because we aren't in control of the decision. |
@bradwilson does then using Thank you in advance! |
@elpht wrote:
If you're using VSTest (whether through Visual Studio or the I'm not aware of any plans on the VSTest side to modify their behavior in a way that would allow us to properly make fine-grained parallelization decisions. That said, if your goal is to just turn off parallelism from the command line, that's something we can accomplish today. You can run multiple assemblies, with parallelism turned off, from the
Here's what it looks like when we run all projects via You can see in this example that VSTest has created two instances of our adapter, and runs each individually without the other knowing. This is why The total run time here is a the expected 10 seconds from running everything in parallel (plus the overhead performed by
The command line can accept multiple test assemblies, and it will run them sequentially by default: Again, Unlike Hopefully this illustrates what's going on, and what control you do (and don't) have over everything. If you're unhappy that In v3, we should be able to offer more command line flexibility here with our console runner. Today in v2, our console runner can run multiple test assemblies (with a command line style much like |
Thank you for your detailed explanation @bradwilson. I think this VSTest issue already tackles that matter. |
I don't think it's exactly the same, but it would be interesting to see what their potential solution is. |
Answering here, rather than in microsoft/vstest#4044 (comment) to keep the context.
I don't think we (vstest / dotnet test) are limiting the parallelism that xunit can do (to serious degree). Both dotnet test and vstest can run all dlls in parallel, but they do it in a different manner:
In theory we would be able to hand out all the assemblies to xunit and let you parallelize on process-level. But that would also make the whole datacollector infra useless (which is our problem of course, not yours). What are the fine-grained decisions and optimizations you would be doing? As far as I am aware you need to start 1 process per .NET assembly because of deps and runtimeconfig json. And either share .NET Framework process and isolate in appdomains, or run 1 per each. Are you talking more about a scheduling level? e.g. this assembly has 10k tests, lets run 5k in one process and 5k in other? |
There is no In addition, this is what I see when trying to use The fact that MSBuild "does the parallelism" is an artifact that nobody here likely cares about. If you want to make it easy to tell people how to turn off parallelism, then I would assume you'd add a documented switch in the (As an aside, it makes sense that MSBuild "does the parallelism" because the output when running multiple assemblies in parallel with
This entire discussion is about how we expose assembly parallelism to users via That is the fine-grained decision I was talking about.
This part will be irrelevant in xUnit.net v3 since everything is a process.
No. |
Followed the documentation for changing parallel settings using
xunit.runner.json
however the runner doesn't respect these values in Visual Studio.Steps to reproduce
https://github.com/abowen/xUnit.Parallel.Example
I opened the issue on Microsoft's Developer Community and they sent me here
https://developercommunity.visualstudio.com/content/problem/838033/xunit-parallel-settings-not-being-respected-by-vis.html
The text was updated successfully, but these errors were encountered: