DEV Community

Sandor Dargo
Sandor Dargo

Posted on

What are the differences between production code and test code?

Let's say this is like a sort of survey. How do you see the differences between production code and test code?

Feel free to add anything that comes to your mind.

Let me start with two things.

  • Production code often tends to be DRY, test code tends to be more WET (Write Everything Twice)
  • Production code tends to be generic, while test code tends

Unleash your mind!

Top comments (4)

Collapse
 
teachingtls profile image
teachingtechleads

Production code is only what is necessary to get the test code to pass. And then refactored to make it clean.

Test code is easily readable and rather blunt. When someone wants to know how the system works, you should be able to point them to the tests that prove the functionality.

Collapse
 
blindfish3 profile image
Ben Calder

Production code is written in a hurry and is most often tested by users because there wasn't time for QA and you were under pressure to release.

Who gets time to write test code?

:P

Collapse
 
alansolitar profile image
Alan Solitar

production code is is written to be robust(ideally, but not always the case).

test code is written just as a poc(proof of concept).

Collapse
 
vlasales profile image
Vlastimil Pospichal • Edited

The difference is in purposes. Production code is for fulfilling the contract. Test code is for verify this contract.