简体   繁体   中英

lein test (:numbers) example

From

 lein help  test

,,

(deftest ^:integration network-heavy-test
   (is (= [1 2 3] (:numbers (network-operation)))))

What is

  (:numbers (network-operation)

doing here?

I added the network-operation function and understand network-heavy-test2 (and it as expected passes.

I assume that (:numbers ..) or :numbers needs to be added / defined / called somewhere?

network-heavy-test fails with

FAIL in (network-heavy-test1) (core_test.clj:23)
expected: (= [1 2 3] (:numbers (network-operation)))
actual: (not (= [1 2 3] nil))

....

(defn network-operation [] [1 2 3])

(deftest ^:integration network-heavy-test2
  (is (= [1 2 3] (network-operation))))

(deftest ^:integration network-heavy-test
   (is (= [1 2 3] (:numbers (network-operation)))))

:numbers , when called as a function, looks up the key :numbers in a map. So, network-operation must return a map:

(defn network-operation []
  {:numbers [1 2 3] :extras "whatever"})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM