With the addition of :portal.viewer/test-report
, Portal can now render your
clojure.test
output!
However, there is no automatic mechanism for delivering test report data directly to Portal, that integration is up to you.
To get started, let's assume you have the following tests:
(ns user
(:require [clojure.test :refer [deftest is] :as t]))
(deftest hello-world
(is (= 0 0))
(is (= (name :hello) (name :world))))
There are many ways to run clojure tests, but an easy way is via clojure.test/run-tests, so let's go with that.
(defn run-test [ns]
(let [report (atom [])]
(tap> report)
(with-redefs [t/do-report #(swap! report conj %)]
(t/run-tests ns))))
(run-test 'user)
That's pretty much it. The key here is that you simply need to intercept values
passed to clojure.test/do-report
and send them directly to Portal.
With the code above, you should get something like:
Although this example is trivial, the main advantage to getting test result out as data is particularly useful when dealing with large values in a test assertion.
You can select two test output values and diff them via the
lambdaisland.deep-diff2/diff
command
Can you improve this documentation? These fine people already did:
Alexander Kouznetsov & Chris BadahdahEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close