Most language/database pair have a corresponding mock library. This allows you to create one or more local in memory tables/collections that your code can call against to test program logic. There are also plenty of faker libraries to fill those mock tables with reasonable values.

What I can’t find is a library that allows me to say “Make a table with the following schema, the following faker methods for general values, and the following properties are true for fields X, Y, & Z”. Most fixture libraries seem to let you just point to a JSON/YAML file that gets turned into a table. This doesn't scale. If I’ve got dozens and dozens of tests, I end up making one file with a mishmash of properties all trying to satisfy different tests, or dozens and dozens of fixture files. Neither option is efficient.

I understand that a solver would be needed to confirm that the properties don’t conflict. I would also expect the properties to be declarative rules in a library specific DSL to limit the complexity of the conflict solving to something computable. Still, this seems immensely useful for testing code that contains queries. Another programmer may change the query in the future but any change should still match the asserted outcome of the function containing the query. It also confirms that the query still succeeds even when the data has X before Y, or duplicate values between X and Y, or any other property I want to add.

Despite all my searching, I don’t seem to find anything that does this for any DB/language pair. Having it for one common DB/language pair would make it simple to port the solution for most others. I suspect I am missing a simple but fundamental reason this doesn’t exist. Or, does anyone know of a solution that I may be missing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.