Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark a whole assembly as non parallelizable in NUnit 3?

We have a whole assembly that we would like to mark as non parallelizable in NUnit.

I've found that there is a [NonParallelizable] that according to the documentation can be set to the assembly level. But where should I put it?

Does anybody has an example?

like image 448
J4N Avatar asked Oct 25 '25 04:10

J4N


1 Answers

To apply the attribute to the assembly you should specify its target (MSDN link) - by using assembly: - so you should have:

[assembly: NonParallelizable]

This attribute can be put in any file in the assembly as long as it's not be inside a namespace, but typically the AssemblyInfo.cs file is used for assembly attributes.

For whatever reason the NUnit documentation that you linked to doesn't provide any sample attribute usages, but the source for NonParallelizableAttribute.cs shows there is a parameterless constructor (which I used above).

like image 150
Wai Ha Lee Avatar answered Oct 26 '25 16:10

Wai Ha Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!