JsonLogic is a data format (built on top of JSON) for storing and sharing rules between front-end and back-end code. It's essential that the same rule returns the same result whether executed by the JavaScript client or the PHP client.

Currently the JavaScript client has tests in QUnit, and the PHP client has tests in PHPunit. The vast majority of tests are "given these inputs (rule and data), assert the output equals the expected result."

As the test set grows (and certainly as we add parsers in other languages) how can we maintain just one standard set of test data and expected results that each get executed in each language's testing framework?

1 Answer 1


A simple approach would be to just write one JSON file like:

    [ rule, data, expected ],
    [ rule, data, expected ]

And then in each language, download the file, parse it, and test it, row by row.

My first inclination was to use a CSV (I'm back now to edit that answer), but as soon as the test data includes objects and arrays, suddenly you have a CSV with JSON in the cells, and it becomes eye-stabbingly frustrating to maintain.

  • The Cucumber test framework for Ruby propagates something like this – write your tests in a natural language that's close to the domain, and then write a few lines of glue code to make them executable. This is also an excellent strategy to make your tests language independent.
    – amon
    Oct 28, 2015 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.