Tests in parallel fixtures not running in parallel per namespace #4679
-
I have a test project with several namespaces. I would like each namespace to run in parallel with other namespaces, but for the tests within each namespace to run serially. My understanding from reading the docs is that this can be achieved with In the Namespace1 folder:
In the Namespace2 folder:
When I select and run Am I doing something wrong or could this be an issue with NUnit or the VS adapter? |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments
-
I think this is a bug with Visual Studio and running individual tests. I expect your tests will run in parallel if you run all tests or if you run from the console. |
Beta Was this translation helpful? Give feedback.
-
@rprouse is this a known VS bug or just a guess? Worth filing something with VS itself? Or maybe this is an issue with the NUnit adapter? |
Beta Was this translation helpful? Give feedback.
-
@OsirisTerje can you comment on this? Have you seen this before in VS? |
Beta Was this translation helpful? Give feedback.
-
I wasn't even aware that you could run namespaces in parallel. It is not in the docs, https://docs.nunit.org/articles/nunit/writing-tests/attributes/parallelizable.html And, if I try it with VS it doesn't, but also when I try this with the NUnit3-console, it doesn't there either. @madelson , how did you manage to run these in parallel? |
Beta Was this translation helpful? Give feedback.
-
@OsirisTerje I did not successfully get the namespaces to run in parallel, hence my post ;-). I wonder if there is a better pattern for doing this? For example, I could set |
Beta Was this translation helpful? Give feedback.
-
If you move the namespaces into separate test projects, they will run in parallel, then it is the testhost doing that. |
Beta Was this translation helpful? Give feedback.
-
My tests are independent, but each namespace uses a different external resource (local database server) and I find that running in parallel within the namespace results in a higher rate of timeouts and transient failures. |
Beta Was this translation helpful? Give feedback.
-
@mandelson Sorry for not responding further (got lost in time. Afaik you can't run namespaces in parallel. You have to split into different projects, that would do it.
Where did you see this in the documentation? @rprouse Would you like to add the possibility if at all possible, to run namespaces in parallel? If not doable, then this issue should be closed. |
Beta Was this translation helpful? Give feedback.
-
@OsirisTerje sorry for the delayed response. I was looking at this page. It says "Parallel SetUpFixture with non-parallel test fixtures: The group runs in parallel with other fixtures and groups. Within the group, only one fixture at a time may execute." I read this as describing the behavior I want. Do you agree? |
Beta Was this translation helpful? Give feedback.
-
I agree that looks promising for what you want to achieve. But the fixtures then need to be set to NonParallelizable. To check this out you can write a small repro, you can add that to the brand new nunit.issues repo. We can then try to work with it together to see if there is something you need to do in the code, or if the documentation is wrong. |
Beta Was this translation helpful? Give feedback.
-
@madelson Did you get any further with this? |
Beta Was this translation helpful? Give feedback.
-
@OsirisTerje sorry I've been busy and haven't gotten back to this. I still plan to if I can. |
Beta Was this translation helpful? Give feedback.
-
@madelson I think this is because you didn't have
which shows that:
so I think the documentation is correct? |
Beta Was this translation helpful? Give feedback.
@madelson I think this is because you didn't have
[Parallelizable]
forpublic class Test
. I tried to reproduce this in Bartleby2718/nunit-parallel-execution@e059d1b and got the following output: