NUnit: a global configuration device that is not used when starting the device to run on the command line

I have a unit test assembly using NUnit that contains thousands of tests in different namespaces and fixtures.

I want to run some global configuration before running any tests in my build (setting up Trace listeners). I can do this by creating [SetUpFixture] in the global namespace.

This works well for all tests, for example:
nunit.exe testassembly.exe

However, if I specify a device for testing, then the global configuration will not start, for example:
nunit.exe testassembly.exe /fixture=MyTests

How to provide a global setting that always starts before running any tests in the assembly?

UPDATE:

Please note that the console test runner will work fine using the /run option, i.e. global configuration is launched even when only a specific test device is launched. I get a solution for a GUI tester.

+6
source share
1 answer

Charlie Poole suggested an alternative in the NUnit discussion forum.

The recommended workaround is to enable all settings and shutdown at the instrument level using [TestFixtureSetup] and [TestFixtureTearDown] .

Global configuration and shutdown can be achieved as follows, using the base class for test devices to share code between devices. For a global installation designed to run once before any mount, a flag can be used to prevent it from being executed multiple times.

PS The / fixture option is obsolete days.

+7
source

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


All Articles