Tutorial :Unit testing on a build server : Release or Debug code?



Question:

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).


Solution:1

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.


Solution:2

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.


Solution:3

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.


Solution:4

Despite most people obviously favour to unit test the release code, I wonder whether the debug build might uncover more errors, though. (I might be wrong)

E.g. afaik in VS debug code, uninitialized variables are forced to some awful value instead of being 0 "by accident". Maybe in .NET it does not make a big difference, but for me, doing mainly algorithmic core code in C++, this can be crucial.

I look forward to any enlightening comments ;).


Solution:5

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


Solution:6

Just adding another reason to test in release mode. Some CI services (Appveyor) will fail the build if it comes across a Debug.WriteLine() call, even though the test itself is green.


Solution:7

We are running both, Debug + Release.

We output a separate tests results xml for each build.

Sometimes there are errors in Debug only, and sometimes in Release only, you want to catch them all ASAP.

Good luck!


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »