0
votes

We use NUnit for implementing GUI tests. We have multiple TestFixtures (Test Suites) focused on a set of application functionalities. Test suites have different priorities of execution ( E.g.: Set A need to be verified before running Set B, because Set B uses functionalities from Set A).

My question is: Is there any way how to run test suites in given order using NUnit-Console?

I've tried passing parameter /test for every test suite, parameters were passed in test suite execution priority order, but it didn't work as I expected, test suites weren't executed in required order.

The line was something like that: "[nunit-console runner path]" /test Tests.TestSuiteWithPriority01 /test Tests.TestSuiteWithPriority02 tests.dll

1

1 Answers

0
votes

The --test command-line option is used to construct a filter, which determines which tests are run. It doesn't affect order - no command-line options have to do with order. NUnit applies the created filter to the tests as it examines them, deciding one test at a time whether it should be executed.

Neither the order of the options nor the order in which NUnit examines the tests has any connection to the order in which they are executed. The execution order is determined by:

  1. Any OrderAttributes you use in your tests.
  2. If no such attributes are used, the order is unspecified. (*)

You can specify [Order(n)] on any fixture or method. Those items with an OrderAttribute execute first, starting with the lowest value of n. If you are running tests in parallel, the order doesn't guarantee that following tests will not start while the first test is running. It's up to you to ensure you don't run such tests in parallel.

See the docs as well: https://github.com/nunit/docs/wiki/Order-Attribute

*Note: some people use the alphabetical order of tests. Some versions of NUnit, in some environments use that ordering. It's not guaranteed by NUnit, so it's not a good idea to rely on it.