Testing with Transcriptor


Hi all,

I’ve been playing around with Stuart Halloway’s transcriptor library for writing example-based tests, primarily because its simplicity was really appealing and its use of spec, but I’m hitting some blockers particularly when attempting to do integration testing.

To be a little be more specific I’m developing a library that will allow users to use their preferred SQL vendor (e.g. postgres or mysql), which of course means there exists vendor specific SQL in a few places. This of course means that my integration tests should be applied against all SQL vendors my library supports and this is really the crux of the problem.

I eventually want to be able to run these tests through a build pipeline by potentially setting up some kind of alias in a deps.edn file, the problem lies in conveying which database vendor context I want to run my transcriptor scripts under.

My initial approach was to set up a main function that acts as the test-runner which accepts some command line args, one of which would be the name of the database vendor, using this data I could then decide which database to spin up and perhaps bind that connection to a dynamic var that my tests could make use of, and then potentially clean up that connection inside the exit-on function. I would then invoke that main function for each vendor I wanted to test.

However I’m beginning to wonder if transcriptor is perhaps too lightweight, and maybe something like greenlight would be better, at the cost of simplicity, the extra legwork I’m having to do makes me think so. Has anyone had any experience using transcriptor for these sorts of tests? (or integration tests in general).

Any advice would be much appreciated!


Based on writing multi-database tests for clojure.java.jdbc and next.jdbc, I’d say that you’re going to need some sort of “test fixture” machinery that lets you run tests for each specific database – and this is a case where I think you might just as well use clojure.test because it already has fixture support.

See https://github.com/seancorfield/next-jdbc/blob/master/test/next/jdbc/test_fixtures.clj for example.

Transcriptor doesn’t support any parameterization of tests so you’d have to use some global state for the context of your tests – something fixtures make a lot cleaner, in my opinion.


Yeah I’m beginning to think the same thing, without writing some kind of wrapper around Transcriptor I feel like I’m trying to squeeze too much out of a library that probably wasn’t designed for the heavy-weight testing that I have in mind.

I’m debating between going back to clojure.test and greenlight, greenlight’s composability is quite attractive, its use of steps provide a lot of useful information, especially when tests fail.

1 Like