Something I've noticed recently is when I am doing the following types of projects:
- When beginning a project
- Working on an MVP/prototype
- Adding features which aren't entirely defined
- Working on a smaller scale project
For reference, I am working on a Python project now which currently has ~1k lines of code, including some comments and all whitespace.
I find it immensely easier to first write integration tests, work on the code, and then once it the API is somewhat hardened actually work on adding unit tests. The types of tests that I can run on my
main function, so to speak, and are more "end to end" than anything else.
This is because unit tests are really annoying when an API is changing fairly rapidly, which often is the case when working on a project matching any or most of the criteria above.
Is this approach a good approach and what criteria should be considered when making the decision whether to start with unit or integration tests first for these types of projects? Am I missing the value of unit testing these sorts of projects before the APIs are more solidified?