How do I get developers to treat test code as "real" code?
- by womp
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?