Keep test code and application code separate
source link: https://www.codewithjason.com/keep-test-code-and-application-code-separate/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Keep test code and application code separate
Sometimes you’ll be tempted to add things to your application code that don’t affect the functionality of your application but do make testing a little easier.
The drawback to doing this is that causes your application code to lose cohesion. Instead of doing just one job—making your application work—your code is now doing two jobs: 1) making your application work and 2) helping to test the application. This mixture of jobs is one straw on the camel’s back that makes the application code just that much harder to understand.
Next time you’re tempted to add something to your application code to make testing more convenient, resist the temptation. Instead add it somewhere in the code that supports your tests. This may take more time and thought initially but the investment will pay itself back in the long run.
Post navigation
← Modeling legacy code behavior using science
Leave a Reply Cancel reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK