1 min readOct 18, 2019
Creating tests is always a subjective affair. Whenever you are creating a test you should focus on the following:
- Improve code quality: if a test doesn’t require specific code to back it up is not necessary. Eg: error scenarios like missing data, network, exception handling, etc
- Sanity checks: sometimes you just want a safety net around your code. Adding tests to hold the minimum requirements is better than nothing. Eg: Input and Output type checking, mandatory information is present, etc.
- Business requirements. Tests should back up business requirements through out the code base. Eg: customer requires a valid address and contact.
- Technical requirements. Tests should validate data, inputs, outputs, internal logic.
- Tests are subjective. My expectations will be different than yours but having tests is always better than having nothing.
- Tests foundation for maintenance/refactorings. You can incrementally improve your tests and confidently support more features/complexity.
All of these apply to Services too. Sometimes you also want to be able to run manual tests against real endpoints to quickly verify that they are behaving correctly as for specifications.