try
Try is a library for unit testing with equal support for interactive and non-interactive workflows. Tests are functions, and almost everything else is a condition, whose types feature prominently in parameterization. Try is what we get if we make tests functions and build a test framework on top of the condition system like Stefil did but also address the issue of rerunning and replaying, make the IS check more capable, use the types of the condition hierarchy to parameterize what to debug, print, rerun, and document the whole thing.

The IS macro is a replacement for assert, that can capture values of subforms to provide context to failures:

(is (= (1+ 5) 0)) debugger invoked on a TRY:UNEXPECTED-RESULT-FAILURE: UNEXPECTED-FAILURE in check: (IS (= #1=(1+ 5) 0)) where #1# = 6
Note the #N# syntax due to *PRINT-CIRCLE*.

This is how to define an run tests:

(deftest should-work () (is t)) ;;; non-interactive (try 'should-work) .. SHOULD-WORK ; TRIAL-START .. ⋅ (IS T) ; EXPECTED-RESULT-SUCCESS .. ⋅ SHOULD-WORK ⋅1 ; EXPECTED-VERDICT-SUCCESS .. ==> #<TRIAL (SHOULD-WORK) EXPECTED-SUCCESS 0.000s ⋅1> ;;; interactive equivalent (should-work)

Test suites are simply test functions that call other test functions.

TRIAL objects record results and are funcallable. Calling TRY or funcalling the trial reruns tests with unexpected results:

;;; non-interacive (try !) ;;; interactive equivalent (funcall *)

Try is not small, but it has a regular design and very few core concepts.

HTML documentation: https://melisgl.github.io/mgl-pax-world/try-manual.html

Repository: https://github.com/melisgl/try

Author: Gabor Melis


Test Framework, MIT-LICENSE