views:

83

answers:

4

In .NET(C#) is there any advantage/disadvantage to go with debug/release build for unit testing?

Which target configuration do you usually use for unit testing on a build server? Does it matter?

What about code coverage (for this one I'm guessing debug versions are needed).

+2  A: 

You must test the code the way it will ultimately run on the client's machine. In most sane deployment scenarios that will be code compiled in the Release configuration.

Hans Passant
We actually deploy Debug versions of our code so we can see the entire stack trace when an issue occurs. Of course all of our code is only used internally.
mpenrow
You are aware that the Release build also produces a full stack trace? You get line numbers if you copy the .pdb files.
Hans Passant
When you select "optimize code" (which is usually the case in release build) can't method get inlined or move around slightly that would cause the line number reference to be somewhat misleading?
Benoittr
I don't get it. You said you deploy Debug builds but you selected an answer that said to unit-test the Release build. Makes no sense.
Hans Passant
+1  A: 

It is easier (for me) to get to the root of an exception when testing debug code.

kbrimington
+4  A: 

I'd recommend running the release code. For a couple of reasons.

1) It is the code that the customers will be using.

2) Some code has special debug conditionals that will produce differences between the debug and release builds.

Jerod Houghtelling
+2  A: 

I would use release build when possible, to get everything as close to the final product as possible.

There are small differences between debug mode and release mode that normally only make a difference for performance, but not result. However, if there is some timing problems with the code they may only show in release mode, so you could take the opportunity to possibly catch those.

Guffa