DEV Community

loading...

Discussion on: Top 3 mistakes you're probably doing while unit testing

Collapse
afifsohaili profile image
Afif Sohaili • Edited

Relying on external resources. How many times have we seen a "testing database" being created and destroyed during the tests execution?

Correct me if I am wrong, but I think if the test is spinning up databases and making real writes and reads it would have been integration tests, not unit tests.

I would also add "mocking critical inputs" into the list. That prevents the tests from having any values, since we're asserting what we ourselves mock in the first place.

Collapse
deleteman123 profile image
Fernando Doglio Author

Correct me if I am wrong, but I think if the test is spinning up databases and making real writes and reads it would have been integration tests, not unit tests.

That is completely correct, that would be an integration test, not a unit test.

As for the mocking critical inputs, could you provide an example? I don't think I'm following.