How to apply the NUnit attribute to an assembly

According to the documentation, you can apply the NUnit timeout attribute to the assembly:

The attribute can also be indicated on the instrument or assembly, in which case it indicates the default timeout for any subordinate test cases.

The problem I am facing is that they do not give instructions on how to apply the attribute to the assembly on this page or anywhere else that I can find in the documentation.

I tried using [SetupFixture] and decorate it with an attribute, but it didn't seem to work. Has anyone had success in creating something like this work?

+6
source share
2 answers

To apply the Timeout attribute to an assembly, first add the using NUnit.Framework; into assembly AssemblyInfo.cs . Then add a line indicating the timeout:

 [assembly: Timeout(1000)] 
+5
source

According to the MSDN page , you can do this using the format you saw in the AssemblyInfo.cs file:

 [assembly: AssemblyCulture("")] 

Therefore, you can probably use:

 [assembly: NUnit.Framework.Timeout(2000)] 

Although I have not tried this.

It should not be in AssemblyInfo.cs , it can be in any file, and if you want to exchange settings in many assemblies, you can define it in one GlobalAssemblyInfo.cs , and then link this file to each project to use the general assembly settings .

+2
source

Source: https://habr.com/ru/post/978414/


All Articles