3 ms·
I haven't found the distinction between unit tests and non-unit tests to be that useful in practice. The important questions are: 1. Is it kinda slow? (The tes
by physicles 3y ago
I haven't found the distinction between unit tests and non-unit tests to be that useful in practice. The important questions are:
1. Is it kinda slow? (The test suite for a single module should run in a few seconds; a large monorepo should finish in under a minute)
2. Is there network access involved? (Could the test randomly fail?)
3. Do I need to set up anything special, like a database? (How easy is it for a new developer to run it?)
If the answer to any of those is Yes, then your test might fall in the liminal space between unit tests and integration tests -- they're unit-level tests, but they're more expensive to run. For example, data access layer tests that run against an actual database.
On the other hand, even if a test touches the filesystem, then it's generally fast enough that you don't have to worry about it (and you did make the test self-cleaning, right?) -- calling that test "not a unit test" doesn't help you. Likewise, if the database you're touching is sqlite, then that still leaves you with No's to the three questions above.