Does NUnit Support Assembly Demonstration Concept?

Does NUnit support a build failure concept similar to Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyCleanupAttribute , which can be applied to a static method?

This will start after all tests in the assembly are complete. I am currently using NUnit 2.6.0.

+6
source share
2 answers

It turns out that this functionality exists in NUnit, it's just not very obvious or intuitive.

According to Charlie Poole in the function request I made for this function here , he claims that the following will work, which is a direct quote from him.

Decorate the class outside of any namespace with [SetUpFixture]. Decorate the method of this class with [TearDown]. If you want, decorate another with [SetUp].

Differences from what you ask for:

  • The name makes this a bit unobvious in this use.

  • NUnit allows any number of them and calls them all, without any guarantee of order. This is by design.

  • It can be applied to a static or instance. If this is an instance method, the class must have a default constructor, and it will be created with the duration of the entire test run. It is also a design.

Now it’s not very, but it should achieve the same functionality, and maybe it will make it a little cleaner in 3.0. :)

+6
source

NUnit has no such concept. But you can apply TestFixtureTearDownAttribute to the method to free resources received by TestFixture.

+1
source

All Articles