You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think it would be great if we could write tests in a normal namespace/file (which clerk embraces as its notebook "story" format) and each notebook would be one kind of test or test suite in which you can make assertions with the normal clojure.test stuff.
This would blur the lines between a test suite and documentation, since you only have to write the notebook once for both doc + test purposes.
The notebooks could then be run using a normal clojure.test runner as if you're running normal tests.
notebook.clj:
(nsmy-lib-test (:require [my-lib :as ml] [clojure.test :as t]))
;; Hello, this is how my library works!
(defx (my-lib/calc {:foo1} :foo))
(t/is (=1 x))
;; The end
runner.clj:
(clerk/deftestmy-lib-test"notebook.clj")
(my-lib-test) ;; runs clojure.test test
(t/run-tests *ns*)
It would perhaps make sense to not render successful assertions (as to not distract from the story) but to render only failing assertions as some warning in the resulting notebook rendering.
The rendered output can then be uploaded to Github pages and serve as documentation for a library.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I think it would be great if we could write tests in a normal namespace/file (which clerk embraces as its notebook "story" format) and each notebook would be one kind of test or test suite in which you can make assertions with the normal
clojure.test
stuff.This would blur the lines between a test suite and documentation, since you only have to write the notebook once for both doc + test purposes.
The notebooks could then be run using a normal clojure.test runner as if you're running normal tests.
notebook.clj:
runner.clj:
It would perhaps make sense to not render successful assertions (as to not distract from the story) but to render only failing assertions as some warning in the resulting notebook rendering.
The rendered output can then be uploaded to Github pages and serve as documentation for a library.
Beta Was this translation helpful? Give feedback.
All reactions