Shinmera / parachute

An extensible and cross-compatible testing framework.
https://shinmera.github.io/parachute
zlib License
97 stars 9 forks source link

Example of with-fixtures ? #41

Closed snunez1 closed 2 years ago

snunez1 commented 2 years ago

I'm having a tough time figuring out with-fixtures. I'm trying to port tests from cl-unit, for example:

(deffixture basics (@body)
  (let ((v #(1 2 3 4))
        (b #*0110)
        (s #(a b c d)))
    @body))

(deftest creation (basics)
  (let* ((plist `(:vector ,v :symbols ,s))
         (df (apply #'df plist))
         (df-plist (plist-df plist))
         (df-alist (alist-df (plist-alist plist))))
    (assert-equalp #(:vector :symbols) (keys df))
...

If github is to be believed, @Shinmera doesn't use with-fixtures in any of his tests. At least a github search didn't turn anything up for that when searching the user repos. Sabra Crolleton's example uses functions/macros that don't seem to exist in Parachute, like def-fixture.

Can anyone provide a simple example of using fixtures?

Shinmera commented 2 years ago

The documentation provides some examples. If all you want is to provide some local bindings around your tests, the easiest is to just define a macro and wrap your stuff in that. The fixtures in parachute are meant to ensure global bindings stay the same.