Daily Usage Issues

Is it possible to list tests in code order, in the test window

Started by AlexV on 2,789 views

By clicking on the Name column I can toggle between alphabetical, reverse alphabetical, and some unknown third state. Is there any way to get it to list the tests in their natural order, though, how they appear in my source code?
Hi, thanks for posting.

At the moment, it isn't possible to do this. Could you elaborate on why you'd like to do it?
Oh, that's a shame. Sure, I'll elaborate.

When I'm going through a fixture full of tests that have gone red, I typically start at the top of my file and work my way down. If I want to check the trace output, or run the test under debugger, or in any way interact with the test in the test window, I naturally click on the test at the top of the list, expecting it to match the test at the top of the file. Even though I know it isn't, I still keep getting tripped up by this. Then I have to search through the list trying to find the right test to select, where often the relevant bit of the test name is at the end of the name and is clipped by the column width. Makes it quite inconvenient.

Also, tests are often (very) loosely grouped together by position in the file. If it's not a strong enough relationship to be worth creating a new fixture for (and breaking the one fixture per class under test convention) then I might have, for example TestAddPerson, TestDeletePerson, TestUpdatePerson method all next to each other, then some other non-Person related tests too.

There's workarounds, I guess, I could rename my tests, or avoid using the test window and use the in-editor popup (for some stuff, other's like the trace output can't be had here), but I find the in-editor UI significantly less convenient than the test window. I think because it's a small target to hit, then a context menu and a new visual search for the UI element to hit and moving the mouse again. Compared to, once the test is selected in the test window, just a single click on the toolbar button that is always in the same place. Really minor stuff, but I think that's why I find it more 'expensive' using the in-editor UI to the test window.
Oh, one thing I should probably have mentioned, I start from the top and work down not just out of habit, but because of the way tests are written code-order is usually a good analogue for increasing complexity and dependency. For example, in a fixture there might be:

TestStoreAndRetrieve
TestMultipleRetrievesAreCached
TestSimultaneousMultiThreadedRetrieve
TestQueuedMultiThreadedStore

And so on. The point is, if TestStoreAndRetrieve is red then there's no point in even investigating failures of later tests until that one is resolved. There's not necessarily a strict dependency or anything, it's just that when you're writing the tests we tend to start with the simpler cases and write more complex ones after being confident of the basic behaviour.
Thanks, this makes sense. Could I interest you in adding this as a feature request on uservoice? This will allow us to track it and implement it if it's popular enough.

Post a reply

Log in to reply.