Run feature test in parallel does not respect "maxParallelThreads" in xUnit #328
-
I'm migrating my specflow test project to reqnroll, I've been able to fix some issues I've found, but there's one issue I'm not able to fix. I used to run the feature files in parallel in specflow where the maxParallelThreads set the maximum number of feature files to run in parallel, so if set to 2 there where 2 drivers running all the scenarios from that feature file and no other feature file started until one was finished. But what currently happens is that at the start the max threats are respected and only that number of feature files are run, but as soon as one of the scenarios has finished (even though there are many more in that feature) another feature has started and it continues without respecting the maxParallelThreads. This is my xunit config file (which worked with specflow)
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 11 replies
-
I have tried to reproduce this with our basic sample project: https://github.com/reqnroll/Reqnroll.ExploratoryTestProjects/tree/main/ParallelExecution/ReqnrollCalculator.Specs.XUnitFw, but could not. In that sample there are 3 feature files and if I set the "maxParallelThreads" to "2" from json (or from code) it completes the two features is starts with and only after it continues with the third one. Could you please try to reproduce it on a minimalistic sample project that you can share? In addition to that, you can try to change the config from code, instead of json to check if it has any impact (see sample here). Also you can try to make some logging to a file, like what I do here. This produces a log file where you can track the execution order. In my example it produced:
|
Beta Was this translation helpful? Give feedback.
-
Hi @gasparnagy thanks for your answer, I tried to log the order of the test, in this case I run 3 feature files with the maxParallelThreads set to 2 also, the Auth has 5 tests scenario outlines for a total of tests, the Products has 7 tests scenario outlines for a total of 7 tests and the FileProcessor has 3 scenario for a total of 3 tests and also I have a [ScenarioDependencies] tag. Looking at the logs I see that it starts running 2 tests but then it continues with 3 and the after feature log is run at the end in all iterations I've tried.
|
Beta Was this translation helpful? Give feedback.
-
I use this file
And this is the configuration I use with specflow, the strange thing is that worker 4 does not start until one test of other workers have finished. As you can see worker 2 and 3 start at the same time and after 48 seconds the other worker starts. Also the all the AfterFeature are run at the same time after all test from all featureFiles have finished, but some features have finished before |
Beta Was this translation helpful? Give feedback.
-
I downloaded your test project
|
Beta Was this translation helpful? Give feedback.
-
Could this be related to xunit/xunit#2003? |
Beta Was this translation helpful? Give feedback.
-
So, for xUnit v2 i think i have now all Information, it's basically "reimplementing" the xUnit v2 is done and finished. To really fix this little flaw the For xUnit 3 i have not looked, but it's seems way different and needs to solve differently, and also we have the offer hat xunit v3 could improved on an API if we have to much work to integrate it. |
Beta Was this translation helpful? Give feedback.
Since Xunit 2.8, Xunit has the
conservative
mode for https://xunit.net/docs/configuration-files#parallelAlgorithm, which then ensures that only such much test are running concurrently which are configured as max threads. That works.However, this does not work with Reqnroll.Xunit. Because the Regnroll runner which is registered with an Assembly Attribute which Regnroll creates does not know about this, and does not switch the mode. I would assume because of backward compatibility from the Xunit side.
I tested this in a case. We had Xunit conservative mode enabled in a project with Reqnroll, all tests would still span up in parallel (e.g.
agressive
mode), even the direct async Xunit tests.T…