I would propose to use three databases. One production database, one development database (filled with some meaningful data for each developer) and one testing database (with empty tables and maybe a few rows that are always needed).
A way to test database code is:
- Insert a few rows (using SQL) to initialize state
- Run the function that you want to test
- Compare expected with actual results. Here you could use your normal unit testing framework
- Clean up the rows that were changed (so the next run won't see the previous run)
The cleanup could be done in a standard way (of course, only in the testing database) with DELETE * FROM table
.