Do you write E2E tests? When do you have too many E2E tests?
What's your general testing strategy e.g. lots of unit tests, few integration tests, fewer E2E, etc.
How do you feel about snapshot tests?
I tend to lean towards a much more heavy E2E testing suite with fewer unit tests. While unit tests are useful to replicate some scenarios, the users will interact with the system as a whole and not a particular class/function in isolation. Unit tests that pass are generally not a good indicator that the system works as a whole.
If it's a micro-service architecture, I would start by
I did use snapshot tests for a mobile application. While being useful in some scenarios, it was a massive pain to maintain. The app was changing so rapidly, it almost made the snapshot testing seem pointless. At scale though, I think this is very useful for checking how your app/website is rendering on the mobile (not so much for the web because form factors are more standard).
Good question. I'm interested to know more about integration tests strategy.
Mark
formerly known as M
As hobby projects, I mostly make small-ish libraries or tools, so integration tests are still small in scope. I usually write some unit tests along with the code, sometimes before sometimes after. Then I try to add a test for most bugfixes to prevent future regression.
It works pretty well. I introduce a lot of types (in Rust) to know that e.g. I'm not mixing up x and y coordinates, or comparing a length to an area. And I add unit tests for non-trivial operations to know that some edge cases work. It finds a lot of logic bugs. Often the overall program works immediately or nearly immediately if it passes all the tests.
For work, I've worked with unit tests, unit tests but with database, and a little with integration tests using Selenium, but overall test coverage was low.
Just last week I found out about mutation testing and I think that's fascinating. Introduce random mutations in the code to see whether tests catch that, as a measure of test coverage! Might be a good test of type safety as well.