简体   繁体   中英

NUnit Running test categories in parallel

I have tests in different classes (Page Object pattern), that may interfere with each other when run together in parallel (they are *not* unit tests). For example, there are classes: AddCustomerFormTests and EditCustomerFormTests , that test adding customers and changing customer info, respectively. The most logical (and readable) solution seems to be to assign the fixtures to different categories and avoid running tests from the same category together, however I can't find a way to do it.

Basically, I'm looking for an equivalent of [Parallelizable(ParallelScope.Fixtures)] that works with categories rather than classes. I don't want to merge classes together cause that would break Page Object pattern, as well as SRP.

Interesting question! I'm afraid I don't think this is currently possible - without making modifications to the NUnit framework. (Although don't take my word for it, others might be able to think of something!)

If you were to consider making changes to the NUnit framework, I would look at implementing a new IWorkItemDispatcher to parallelise work based on categories. You can then just select the correct dispatcher when initialising the TestExecutionContext. (eg https://github.com/nunit/nunit/blob/ad943eb94fe280e661fc6c690043fe8eb0a11e40/src/NUnitFramework/framework/Api/NUnitTestAssemblyRunner.cs#L352-L358 )

An alternative way around the problem - have you considered using partial classes to group your tests, and then parallelising fixtures? I think that would work...you'd probably want to test this out first!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM