We already have such an attribute, but it has a different syntax.
Decorate a class outside of any namespace with [SetUpFixture].
Decorate a method of that class with [TearDown]. If you like, decorate
another with [SetUp].
Differences from what you are asking for:
1. The name makes it a little unobvious in this usage.
2. NUnit allows any number of these and calls them all, without any
guarantee of ordering. This is by design.
3. It can be applied to a static or instance method. If it's an
instance method, the class must have a default constructor and it will
be created with a lifespan of the entire test run. This is also by
design.
I'm open to suggestions for how to change this in NUnit 3.0, but it
shouldn't involve searching all methods of all classes to find the
proper methods. NUnit processes an assembly by looking first at each
class and then deciding what to use it for. We could simply continue
with the existing syntax or supplement it with an AssemblySetUpFixture
(or some other name) that applies to the whole assembly. Suggestions
welcome here.
Meanwhile, I'm making this a wishlist item for NUnit 3.0.
Charlie
PS: It's also possible to accomplish the same thing by defining an
ActionAttribute (see the docs).
On Fri, Jan 11, 2013 at 4:03 PM, Rodney Foley <email address hidden> wrote:
> Public bug reported:
>
> It would be great to have an attribute that can decorate a static method
> called AssemblyTearDown. It would mark the method that should be called
> after all the tests within the assembly have run to allow resources
> obtained by the assembly to be freed.
>
> - It needs to be applied to a static method
> - It would be called after all the other TearDown's have been processed.
> - It should not need to be in a class that has test methods.
> - NUnit should only allow one method to be decorated with this attribute within an assembly.
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
>
> ** Tags: feature
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https://bugs.launchpad.net/bugs/1098766
>
> Title:
> Feature Request: AssemblyTearDown Attribute
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/1098766/+subscriptions
We already have such an attribute, but it has a different syntax.
Decorate a class outside of any namespace with [SetUpFixture].
Decorate a method of that class with [TearDown]. If you like, decorate
another with [SetUp].
Differences from what you are asking for:
1. The name makes it a little unobvious in this usage.
2. NUnit allows any number of these and calls them all, without any
guarantee of ordering. This is by design.
3. It can be applied to a static or instance method. If it's an
instance method, the class must have a default constructor and it will
be created with a lifespan of the entire test run. This is also by
design.
I'm open to suggestions for how to change this in NUnit 3.0, but it xture
shouldn't involve searching all methods of all classes to find the
proper methods. NUnit processes an assembly by looking first at each
class and then deciding what to use it for. We could simply continue
with the existing syntax or supplement it with an AssemblySetUpFi
(or some other name) that applies to the whole assembly. Suggestions
welcome here.
Meanwhile, I'm making this a wishlist item for NUnit 3.0.
Charlie
PS: It's also possible to accomplish the same thing by defining an
ActionAttribute (see the docs).
On Fri, Jan 11, 2013 at 4:03 PM, Rodney Foley <email address hidden> wrote: /bugs.launchpad .net/bugs/ 1098766 /bugs.launchpad .net/nunitv2/ +bug/1098766/ +subscriptions
> Public bug reported:
>
> It would be great to have an attribute that can decorate a static method
> called AssemblyTearDown. It would mark the method that should be called
> after all the tests within the assembly have run to allow resources
> obtained by the assembly to be freed.
>
> - It needs to be applied to a static method
> - It would be called after all the other TearDown's have been processed.
> - It should not need to be in a class that has test methods.
> - NUnit should only allow one method to be decorated with this attribute within an assembly.
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
>
> ** Tags: feature
>
> --
> You received this bug notification because you are subscribed to NUnit
> Extended Testing Platform.
> https:/
>
> Title:
> Feature Request: AssemblyTearDown Attribute
>
> To manage notifications about this bug go to:
> https:/