1

I have unittest case project where TestSetup is globally setup for all test files.

[SetUpFixture]
public class TestSetup
{
     [Setup]
     public TestSetupMethod(){}
}

How to skip test setup to call for particular nunit unit test case. all other unit test case need this but for couple of unit test case where it is not require.

1 Answer 1

2

From the documentation:

This is the attribute that marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace.

So simply add all unit tests that requires the one-time setup in the namespace of your setup class, all that don't require that setup in another.

7
  • I want to skip [setup] to call for particular unit test case. How to ignore to call for specific uni test case? currently, at project level these files are placed and multiple folders separately for group the test cases. so, adding this files in particular folder would restructure. Its bit hard to restructure now stage. any alternate solution ?
    – dsi
    Commented Apr 6, 2017 at 5:11
  • Is it possible to override [setup] so, skip global one and use test file's specified? restructuring name space is not possible now so.
    – dsi
    Commented Apr 6, 2017 at 5:29
  • The code executed by the method with the [Setup] attribute is run once before all fixtures in that particular namespace (or at assembly scope when no fixtures are in that namespace). It does not care about the fixtures in it. Another option would be to use [TestFixtureSetUp] but then you'll obviously also need to restructure your test cases and put all fixtures that require the setup in one, and all that don't require them in another class.
    – MiGro
    Commented Apr 6, 2017 at 5:33
  • ok. so, need some any alternate way then restructure name spaces, to skip test setup to call for specific nunit unittest case. please provide for any alternate way.
    – dsi
    Commented Apr 6, 2017 at 5:36
  • tried with alternate one - stackoverflow.com/questions/1194198/… link but, it not able to fetch category attribute. it shows count 0 for _CATEGORIES property. any idea?
    – dsi
    Commented Apr 6, 2017 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.