On Fri, May 1, 2015 at 5:17 AM, Avraham Serour <
tov...@gmail.com> wrote:
> In my opinion you shouldn't, you should set the test data and make a real
> query then compare results, you shouldn't care how the function got the
> data, but that it got it correctly.
that's part of a much bigger religious war, with "unit tests" at one
extreme and "integration tests" at the other.
even without aiming for unittest purity, the "test only the code
you're testing" idea would clearly advise for mocking the database.
of course, that means many more tests for the database layer itself,
which in turn make the OP's wish for quick tests all much more
important.
but when doing TDD, the favored tests aren't necessarily of the
unittest variety; they lean somewhat more towards functional tests,
almost integration tests. IOW: if it's a requirement for the code to
work decoupled from the database, then test it in isolation. if not,
then the minimal test (and minimal code to pass it) is to assume the
database layer is already well tested by the framework (and it is!),
and you're free to assume it in the tests.
cheers,
--
Javier