How to realize fixtures in anticipation of clojure?

I recently started using the Clojure test environment expectations. As part of my test, I have a dataset that I want to reset to its original value before starting a new test / pending statement.

In clojure.test, I would just create a fixture and a call (use-fixtures: each my-fixture-fn).

I was looking for good examples of how to do this on hold, but so far have not had any luck. Can someone provide a specific example of how to implement a device that runs before each test on hold?

+4
source share
1 answer

You can use the let statement with the wait. Maybe something like this will do your job (unverified pseudo-code):

(expect 
 (let [dataset {val: "original values"}]
  (function-to-be-tested val:))
 expected-return-value)

This real code works out of the box to show the principle:

(expect (let [ar [1 2 3]]
   (first ar)) 2)

It returns the following error message as expected:

failure in (core_test.clj:9) : image-lib.core-test
(expect (let [ar [1 2 3]] (first ar)) 2)

       expected: 1
            was: 2

Ran 2 tests containing 2 assertions in 17 msecs
1 failures, 0 errors.
Tests completed at 10:59:45.435
+1
source

Source: https://habr.com/ru/post/1614309/