Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop ReSharper cleanup from reordering unit tests

Tags:

resharper

Currently when I run Full Cleanup on a file with NUnit tests R# totally ruins it. For some reason it reorders the methods with [Test] in alphabetical order. How can I turn this "feature" off?

I'm using version 9.2.

like image 429
Test_me Avatar asked May 14 '26 19:05

Test_me


1 Answers

This is explained in the documentation here

you need to go to Code Editing | C# | File Layout page of ReSharper options and then remove the default NUnit layout pattern (or change it so that it doesn't reorder alphabetically)

The simplest way to do this via the ui (which seems to be very confusing) is to double click each Type Pattern and make sure you are in composition view (click the icon in the top right corner until its a cog) then double click the method Entry elements until you find the one which has the constraint for the attribute for NUnit framework (somethign like this):

enter image description here

and then change the Sort By option in the bottom right of the main settings window to be none

like image 108
Sam Holder Avatar answered May 17 '26 04:05

Sam Holder