My struggles with many DependsOn #1823
Replies: 4 comments 18 replies
-
I think you're probably right. Tests get blocked by a semaphore lock. I would've thought in those scenarios the threads would realise they're inactive, and release back to the thread pool to process other tests that aren't sitting behind a lock. This might be a tricky one to sort. Open to any ideas 😅 |
Beta Was this translation helpful? Give feedback.
-
This could probably be a quick one if it'd help unblock you somewhat |
Beta Was this translation helpful? Give feedback.
-
|
I've been spending some time with release 0.12.17 and changing the arguments of my tests. First of all the However I tried gradually removing my |
Beta Was this translation helpful? Give feedback.
-
|
Things are working great in v0.13.3. @thomhurst Thanks a lot for the quick fixes. I'll continue using TUnit as the project grows and see how things are going, but so far I'm really happy with the results. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, first of all great work on TUnit so far!
I've been trying out TUnit for a new API project where I'm using it for doing integration tests and I wanted to share my experience. I didn't want to create an issue and thought it would be better to create a discussion, as I don't know if my struggles are caused by one or more issues or some limitations to the platform and how I'm trying to structure my test project.
Platform:
Most of my tests use an HttpClient to call a local endpoint and then using Verify on the response.
Tests are grouped in classes like,
SomethingCreateTestsClass : AbstractCreateTestsClasswhere the class either inherits or overrides tests from the base class. The base class has aCreatetest and aGettest that depends on theCreatetest. This structure is repeated forUpdate,Deleteetc.The whole project is comprised of these classes that depend on the class before it so
UsersCreateTestsClassdepends onOrganizationsCreateTestsClass,ProductsCreateTestsClassdepends onUsersCreateTestsClassetc. Some of these classes use aMethodDataSourceon the Class withIEnumerable<Func<T>>.Simplified structure:
So this all results in 100+ tests with a lot of dependencies and this is where things start to break. I would run into situations where later tests become really slow or hang, and the editor will eat up more and more CPU and RAM until it freezes completely. It would also cause failures to not propagate and so the test session would hang again.
I think many of these issues happen because
DependsOndoesn't put tests into aPendingstate where it executes them in order, but instead puts them into theRunningstate. So if aDeletetest runs it would put all dependencies up the chain intoRunning. This also means anAssemblylevelParallelLimitwill break the test session, because dependencies never resolve.At first I was able to resolve these issues by using
ParallelGroupsand limiting the amount ofDependsOn. However as the project grew this wasn't enough and I needed to useNotInParallel(Order = x)in addition to theParallelGroupsand removing moreDependsOn.My ideal setup for a project like this would be to have
ParallelGroupsthat can depend on otherParallelGroupsand then within these groups I could have tests that depend on other tests like it works now.ParallelGroupswith anOrderproperty could probably also be useful.I hope this is helpful.
Beta Was this translation helpful? Give feedback.
All reactions