I’m helping put together some automated tests for a large Python project, and a question has arisen - how should test code style relate to library/application code style?
From reading various test suites over the years, I’ve observed that tests have fewer abstractions! It’s common for test suites to be quite “boring”. There may be a few utility functions, but usually not complex class or object ownership hierarchies. This makes the code more repetitive and probably violates DRY and some other acronyms.
I think the aim here is to make the learning curve for any given test a little gentler. If I see a test fail and need to debug it, I don’t need to understand anything about the test suite architecture - I just need to read the test. The cost of this is that the overall test architecture may be less elegant and more repetitive.
My understanding here is broadly intuitive and I’d like to:
- Check it’s actually right!
- Find some more scientific grounding for this approach
Does anyone have any views on the topic? Or any recommended reading? (Books, blog posts, etc?)