Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • Wouldn't you be testing whether or not the database contains certain data? Commented Nov 2, 2015 at 20:04
  • Possibly - but you could also be testing that your filters, complex joins, etc. work. The example query is probably not the best candidate for "unit tests" but one with complex joins and/or aggregations might. Commented Nov 2, 2015 at 21:45
  • Yes - the example I used, as pointed out, is trivial; a real repository could have all manner of complex search and sorting options, e.g. using a query builder, etc. Commented Nov 2, 2015 at 22:02
  • 2
    Good answer, but I would add that the DB should be in memory, to make sure that unit tests are fast. Commented Nov 3, 2015 at 13:03
  • 4
    @BЈовић: Unfortunately, that might not always be possible, since unfortunately there are no two compatible DBs out there and not all of them work in memory. There are also licensing issues for commercial DBs (you might not have the license to run it on any machine), ... Commented Nov 3, 2015 at 14:21