J4N
J4N

Reputation: 20761

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?

Upvotes: 4

Views: 2603

Answers (2)

Charlie
Charlie

Reputation: 13736

If you have no [Parallelizable] attributes in the assembly, then the assembly is non-parallelizable. Adding a [NonParallelizable] attribute at the assembly level serves only as documentation in this case.

[NonParallelizable] at the assembly level does not override any lower-level [Parallelizable] attributes you may have in the assembly. On the contrary, the lower level attributes override the higher level one.

Upvotes: 0

Wai Ha Lee
Wai Ha Lee

Reputation: 8815

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).

Upvotes: 5

Related Questions