Search code examples
unit-testingagileproduction-environment

Unit tests in production release code?


Couple of questions:

1.) Do you unit test release code?

2.) If so, do you then leave those unit tests intact so that the tests themselves exist in the production environment?

I see the value in #1, but is it a "good practice" to create dependencies in production to, for example, the NUnit assemblies?

Give me your thoughts.


Solution

    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 deploying to non-technical users). However I do have an exception, which is a programming utility that is unit tested with ~130 test scripts. Because the test scripts double as examples, I deploy those along with the production release, and consequently they enhance the existing documentation.

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