3

I want to run some setup (and run it only once for all the tests, currently using SetUpFixture), when running NUnit tests locally, and not to run that setup, when starting unit-tests with nunit-console on build server. Found no proper way to do it with NUnit attributes and nunit-console cmd options.

fspirit
  • 2,537
  • 2
  • 19
  • 27

1 Answers1

0

I can't really imagine a scenario where you would perform some setup in one environment but not another - and the fact that there is no "proper" way within NUnit may indicate that the requirement is worth further consideration. Perhaps if you gave more detail about the context of what you need to set up then we could come up with a better solution, but here are 2 suggestions for setting the server up:

  • Perform setup in a previous server build step before you run your unit tests.
  • Use an environment variable in your SetUpFixture method to detect if you are running on the server. Ideally, this would be a custom environment variable that you configure yourself; if you want a quick-and-dirty, use e.g. JENKINS_URL or TEAMCITY_VERSION depending on your build server.
Rich Tebb
  • 6,806
  • 2
  • 23
  • 25
  • 1
    So I ended up using my custom quickbuild variable, that I passed to nunit-console as environment variable. – fspirit Aug 27 '13 at 13:57