I'd say that the only time you want to incorporate any test code in your final deployment is when the test code is there for monitoring and control of the application.
Leaving the test code in the deployment:
- bloats the code to no real advantage at all - all that extra code tagging along that isn't going to be used at all in situ.
- affects releases - do you release a new version of the complete app. when what you've improved is only in the test code, e.g. a test suite is extended as a result of a bug fix.
- you can't easily reuse the test framework on another project - if you are always releasing app's that are clogged with test code, any subsequent projects have to reuse the same test code. Otherwise, you finish up with the situation where app A is using v1.2 of the test platform for those aspects of the app. that are common across all your app's, e.g. a presentation layer, or a business logic framework, etc. And app. B is using v1.1 of the test framework, app. C is using v1.2.1, etc.
Decoupling on the otherhand allows you to:
- easily upgrade and extend the test suite as required.
- easily reuse the test suite across multiple projects.
- use a common test framework across multiple projects.
HTH
cheers,
Rob