1.3.0 permalink Arrow_down_16x16

testing

clojure.test

  • (testing string & body)
Adds a new string to the list of testing contexts. May be nested,
but must occur inside a test function (deftest).

1 Example top

  • (:use 'clojure.test)
    
    (testing "Arithmetic"
      (testing "with positive integers"
        (is (= 4 (+ 2 2)))
        (is (= 7 (+ 3 4))))
      (testing "with negative integers"
        (is (= -4 (+ -2 -2)))
        (is (= -1 (+ 3 -4)))))
    => true
    
    
    ---------------------------------------------------------------------------
    
    (testing "Arithmetic"
      (testing "with positive integers"
        (is (= 4 (+ 2 2)))
        (is (= 7 (+ 3 4))))
      (testing "with negative integers"
        (is (= -5 (+ -2 -2)))                ;error here
        (is (= -1 (+ 3 -4)))))
    
    => FAIL in clojure.lang.PersistentList$EmptyList@1 (NO_SOURCE_FILE:641)
    Arithmetic with negative integers        ;bread crumb trail
    expected: (= -5 (+ -2 -2))
      actual: (not (= -5 -4))
    true
Log in to add / edit an example.

See Also top

  • 0
    clojure.test/is

    Generic assertion macro. 'form' is any predicate test. 'msg' is an

  • 0
    clojure.test/deftest

    Defines a test function with no arguments. Test functions may call

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/test.clj:573 top

(defmacro testing
  "Adds a new string to the list of testing contexts.  May be nested,
  but must occur inside a test function (deftest)."
  {:added "1.1"}
  [string & body]
  `(binding [*testing-contexts* (conj *testing-contexts* ~string)]
     ~@body))
Vars in clojure.test/testing:
Used in 0 other vars

Comments top

No comments for testing. Log in to add a comment.