▲ | troupo 6 days ago | |||||||
> This I/O might be crafted in ways that never trigger a failure scenario or expose a bug within the lower-level components. You mean just like unit tests where every useful interaction between units is mocked out of existence? > Furthermore, the fact that, by their nature, integration and E2E tests are often more expensive to setup and run, there will be fewer of them And that's the main issue: people pretend that only unit tests matter, and as a result all other forms of testing are an afterthought. Every test harness and library is geared towards unit testing, and unit testing only. | ||||||||
▲ | imiric 6 days ago | parent [-] | |||||||
> You mean just like unit tests where every useful interaction between units is mocked out of existence? Sure, that is a risk. But not all unit tests require mocking or stubbing. There may be plenty of pure functions that are worth testing. Writing good tests requires care and effort, like any other code, regardless of the test type. > And that's the main issue: people pretend that only unit tests matter, and as a result all other forms of testing are an afterthought. Huh? Who is saying this? The argument is coming from the other side with the claim that unit tests don't matter. Everyone arguing against this is saying that, no, all tests matter. (Let's not devolve into politics... :)) The idea of the test pyramid has nothing to do with one type of test being more important than another. It's simply a matter of practicality and utility. Higher-level tests can cover much more code than lower-level ones. In projects that keep track of code coverage, it's not unheard of for a few E2E and integration tests to cover a large percentage of the code base, e.g. >50% of lines or statements. This doesn't mean that these tests are more valuable. It simply means that they have a larger reach by their nature. These tests also require more boilerplate to setup, external system dependencies, they take more time to run, and so on. It is often impractical to rely on them during development, since they slow down the write-test loop. Instead, running the full unit test suite and a select couple of integration and E2E tests can serve as a quick sanity check, while the entire test suite runs in CI. Conversely, achieving >50% of line or statement coverage with unit tests alone also doesn't mean that the software works as it should when it interacts with other systems, or the end user. So, again, all test types are important and useful in their own way, and help ensure that the software doesn't regress. | ||||||||
|