NonTestAssembly
NonTestAssemblyAttribute is used to mark an assembly that references NUnit but does not contain any tests. This is useful for third-party frameworks, extensions, or other software that depend on NUnit but should not be loaded as test assemblies.
Usage
This is a parameterless attribute that can only be applied at the assembly level.
[assembly: NonTestAssembly]
Applies To
| Test Methods | Test Fixtures (Classes) | Assembly |
|---|---|---|
| ❌ | ❌ | ✅ |
Typically placed in AssemblyInfo.cs or a global usings file.
Example
The following code, placed in AssemblyInfo.cs, marks the assembly as not containing tests:
using NUnit.Framework;
[assembly: NonTestAssembly]
Notes
- Use this attribute when your assembly references
NUnit.Frameworkbut is not intended to be run as a test assembly (e.g., test utilities, custom assertions, or framework extensions). - When used with the console runner's
--skipnontestassembliesoption, assemblies marked with this attribute are skipped without generating an error. - Recognition of this attribute depends on the individual test runner. Not all runners may honor it.
- This attribute is marked
[EditorBrowsable(EditorBrowsableState.Never)]to reduce IntelliSense noise in typical test projects.
See Also
--skipnontestassembliesin Console Command Line