Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run NUnit tests in release mode

I have a problem.

#if DEBUG
        ca.ConveyancingAttorneyID = "C0B68DC3-C396-4264-880B-1A699C53A8CE";
        ca.ConveyancingFirmID = "C0B68DC3-C396-4264-880B-1A699C53A8CE";
#endif

When we are running in debug mode, we hardcode the identifier. In release, it's obviously dynamically set.

Now when it comes to unit testing the mapping code, I've had to do this : (initially I just tested the 'Release case', which would then always fail in Debug mode)

#if RELEASE
        Guid id = new Guid("1A92CE5A-D956-486B-9B65-0A3630EF0285"); 
#endif
#if DEBUG
        Guid id = new Guid("C0B68DC3-C396-4264-880B-1A699C53A8CE"); 
#endif

This is not ideal. And having to remember (and remind teammates) to always run the Unit Tests in Release is also a hassle. We don't have a continuous integration setup, so the tests are only ever run locally.

Is there a way to force NUnit / Visual Studio Testrunner / Resharper Testrunner to always run tests in Release mode? Or is there a better way to approach this, keeping in mind that these kind of '#if DEBUG' codeblocks are quite abundant in the solution.

like image 817
Johan Venter Avatar asked Feb 26 '14 09:02

Johan Venter


1 Answers

If you must run Release, use argument /config:Release

like image 194
Xeon Avatar answered Oct 16 '22 22:10

Xeon