How do I get developers to treat test code as "real" code?

Posted by womp on Stack Overflow See other posts from Stack Overflow or by womp
Published on 2010-03-26T19:22:46Z Indexed on 2010/03/26 19:33 UTC
Read the original article Hit count: 391

Filed under:
|
|
|
|

In the last two companies I've been at, there is an overriding mentality among developers that it's okay to write unit tests in a throw-away style. Code that they would never write in the actual product suddenly becomes OK in the unit tests. I'm talking

  • Rampant copying and pasting between tests
  • Code styling rules not followed
  • Hard-coded magic strings across tests
  • No object-oriented thought or design for integration tests, mocks or helper objects (250 line single-function tests!)

.. and so on. I'm highly dissatisfied with the quality of the test code. Generally we do not do code reviews on our test assemblies, and we also do not enforce style or code analysis of them on our build server.

Is that the only way to overcome this inertia about test quality? I'm looking for ideas to take to our developers, without having to go to higher management saying that we need to use resources for enforcement of test quality (although I will if I have to). Any thoughts or similar experiences?

© Stack Overflow or respective owner

Related posts about TDD

Related posts about unit-testing