Daily Usage Issues

Controlling display order of tests in Ncrunch Test window

Started by Phil on 8,363 views

I'm wanting to be able to allow fellow developers to simply read down the list of unit tests and get a good understanding of what each component does and how it should behave. For example, I'd like to see something like:

UnitTests.Day
  • Initialise_FromUnsavedDay_ThrowsException
  • Initialise_FromDayWithZeroStages_LoadsData
  • Initialise_FromDayWithOneStage_LoadsData
  • Initialise_FromDayWithMultipleStages_LoadsData
  • Commit_UnsavedDay_CreatesDayId
  • Commit_SavedDay_DoesNotChangeDayId
  • AddStage_SavedStage_AssociatesStageWithDay
  • AddStage_UnsavedStage_ThrowsException

However the (seemingly) random default ordering produces something like:

UnitTests.Day
  • Initialise_FromDayWithOneStage_LoadsData
  • AddStage_SavedStage_AssociatesStageWithDay
  • Commit_UnsavedDay_CreatesDayId
  • Commit_SavedDay_DoesNotChangeDayId
  • Initialise_FromDayWithZeroStages_LoadsData
  • AddStage_UnsavedStage_ThrowsException
  • Initialise_FromDayWithMultipleStages_LoadsData
  • Initialise_FromUnsavedDay_ThrowsException

Is there anyway to control the order in which tests are displayed in the NCrunch Test window to produce the order I'm hoping for?
Hi Phil,

Thanks for posting!

My observation of the test order is that it is normally alphabetical, although I can't find a mechanism that strictly enforces this (so most likely there are random elements).

It makes sense to me to always have the test order consistent, so I'm thinking I may make an adjustment to ensure that it is always alphabetical. You could then label your tests appropriately (i.e. put letters or numbers at the beginning to define sequence).

Would this work for you?


Cheers,

Remco
Thanks for the response Remco (and for building a fantastic tool !!)...

Having a consistent order is key to me and enforcing alphabetical order would be a workable solution.

I'm guessing that because NCrunch / NUnit uses the assemblies rather than the source code this would make it difficult/impossible to simply display and/or execute the tests in the order they appear in the source files? This approach would be preferable because there would be less overhead involved when inserting new tests (no need to re-number / re-index) and would encourage developers to structure their test classes to "tell a story" about the class under test.
Hi Phil,

Thanks for the feedback. You're correct in your assumption that it is difficult for IL-dependent tools such as NCrunch to use data on source file sequence. It's theoretically possible but very hard and likely not worth the investment relative to other higher value features. Though I definitely agree that this would be a better and more readable approach.

I'll include the alphabetical order fix in the next release (1.41b) :)


Cheers,

Remco

Edited

Excellent - looking forward to 1.41b! :D
This post has been deleted.
For anyone interested, 1.41b has just been released including the above mentioned change (alphabetical order on tests shown in the Tests Window).

Post a reply

Log in to reply.