0

I want to create a report of NUnit tests in a binary.

Currently they are sorted alphabetically as per NUnit defaults, so developers need to do things like

public void ALoginFailed() { ... }
public void BLoginPassed() { ... }

in order to get the desired display order in the report. All tests should run independently, so execution order is not important.

I have thought about adding custom attributes, like

[Test(DisplayIndex = 1)]
public void FirstTest() { ... }

... but to me this seems not very friendly to the developer, especially if you have 50 tests and you want to insert one somewhere in the middle, or if you forget to add a display index somewhere.

Is there another cleaner, more robust way of specifying or influencing the display order, or am I stuck with attributes?

Sounten
  • 192
  • 1
  • 2
  • 10
  • [Related](http://stackoverflow.com/questions/9062235/get-properties-in-order-of-declaration-using-reflection) – user1620220 Jan 22 '15 at 18:35
  • Very strange requirement, nobody ever looks at a list like this. A unit test is only ever interesting when it fails. Having all 50 fail at the same time means the world came to an end, an orderly list of catastrophe doesn't make it better. Avoid adding useless features. – Hans Passant Jan 22 '15 at 18:38
  • 1
    If you don't want alphabetical ordering, which ordering do you want instead? You obviously don't want developers have to specify an explicit ordering. – Christoph Jan 22 '15 at 18:45
  • Forgot to mention, it's not unit tests, it's UI functional tests - and there is a custom UI for viewing the test results. – Sounten Jan 22 '15 at 19:03
  • Without knowing how you want to influence the order, this question can't really be answered. Having DisplayIndex as a float would allow for inserting missed indexes (you'd simply have 1.1, 1.2, 1.1.1 etc if you needed to insert). I've added a general approach to getting a list of Tests in an assemblyin this answer: http://stackoverflow.com/a/30324973/592182 – forsvarir May 19 '15 at 12:47

0 Answers0