[ACCEPTED]-Unit tests in production release code?-production-environment

Accepted answer
Score: 19
  1. Absolutely. If our build passes the unit test suite then it's tagged and a candidate for production
  2. No. Deployments don't include tests nor the supporting libraries (e.g. unit test libraries, mocking etc.)

The above is my general rule (I'm usually 12 deploying to non-technical users). However 11 I do have an exception, which is a programming 10 utility that is unit tested with ~130 test 9 scripts. Because the test scripts double 8 as examples, I deploy those along with the 7 production release, and consequently they 6 enhance the existing documentation.

Deploying 5 tests with open-source code is definitely 4 worthwhile. It allows people to play with, modify 3 and submit patches, whilst being able to 2 run the tests that passed successfully to 1 permit the original artifact to be released.

Score: 8

Yes and Yes, application behaviour can be 3 different between release and debug builds, hence 2 as part of the release process the release 1 build has to pass all its unit tests.

Score: 2
  1. Yes of course! Unit tests run on all build 8 configurations.

  2. Unit tests are always intact 7 but this does not mean that shipped assemblies 6 are dependent on anything relating to the 5 tests. Tests are always written in a parallel 4 assembly (in the same build environment) that 3 then tests the production assembly. The 2 parallel assembly is not shipped as it only 1 contains the tests.

Score: 2
  1. Yes, remember the classic "Assert with side-effects" error that must be caught as well. But this one doesn't need to be done as often as the debug build, where a complete test should be done every day.
  2. Typically unit-tests are in different translation units and in a different project, so that a release build of the main project does not touch them at all. If your unit-tests are in the same translation units as the tested code though, you can use conditional compilation to exclude them from releases.


Score: 2

Depends on the project. Yes to number 1. Following 22 the principal that everything should be 21 checked into source code control and it 20 should be simple to get a new developer 19 going. Make them part of the codebase. New 18 people can do a check out and run the tests.

Whether 17 they are deployed to production is a different 16 issue. I haven't worked on a project that 15 needed them there. Rails' deployment model is 14 (generally) simply a check-out of the whole 13 project on a production machine, so yes 12 they are there. Java/Maven projects have 11 a whole build/packaging step, and generally 10 unit tests can-- and are-- removed when 9 building the final .war file.

Either way, you 8 don't expect them to run. In today's environment, it 7 doesn't really matter if they site there-- memory 6 and disk are so cheap it's really not an 5 issue. I have heard the argument that you 4 don't want the test code on the production 3 server so that there's no risk that it will 2 get run, but I haven't heard of a scenario 1 when this would really happen.

More Related questions