How do I unit test a function that takes a list of maps and returns an HTML table with the same data in Clojure/Hiccup?

1 Answer 1


For such "small" pieces of functionality, I would just perform regression testing on examples. Write a few samples representing some cases you want to deal with, manually build the results, and compare the output.

samples could be:

  • empty list
  • list with 1 entry / 1 col
  • list with 4 entries
  • invalid data (nested map, heterogeneous keys)

This test is brittle, but the scope of the function is so small that it is hard to come up with a good definition for the service provided.

A slightly better way is to parse the html and perform specific assertions on the structure returned by the function (nbr of rows, innerText of a td etc).

Your Answer

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

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