After all, the code doesn't show the 10 most recent customers that purchased an item, it shows ALL customers. You could hide a pagination bug where only the first page of results functions if you wipe the database first.
After all, the code doesn't show the 10 most recent customers that purchased an item, it shows ALL customers. You could hide a pagination bug where only the first page of results functions if you wipe the database first.
Then your test code needs to take into account the current state of the database when creating input data for the code under test. It is more complicated than with a know start state where you can pick fixed data, sure, but it's doable.
... and you're on your way to writing an application, not a test!
Tests should be as simple as possible, and a clean slate goes a long way toward that.
A test should be riddled with as few "needs to do" responsibilities as possible while still achieving the intended coverage.