Back
deftest- (clj)
(source)macro
(deftest- name & body)
Like deftest but creates a private var.
Examples
clojure
(ns clojure.test-clojure.java-interop
(:use clojure.test)
(:require [clojure.data :as data]
[clojure.inspector]
[clojure.pprint :as pp]
[clojure.set :as set]
[clojure.test-clojure.proxy.examples :as proxy-examples])
(:import java.util.Base64
(java.util.concurrent.atomic AtomicLong AtomicInteger)))
(defmacro deftest-type-array [type-array type]
`(deftest ~(symbol (str "test-" type-array))
; correct type
#_(is (= (class (first (~type-array [1 2]))) (class (~type 1))))
(deftest-type-array int-array int)
(deftest-type-array long-array long)
;todo, fix, test broken for float/double, should compare to 1.0 2.0 etc
#_(deftest-type-array float-array float)
#_(deftest-type-array double-array double)
logseq/logseq
(ns frontend.fs-test
(:require [clojure.test :refer [is use-fixtures]]
[frontend.test.fixtures :as fixtures]
[frontend.test.helper :as test-helper :include-macros true :refer [deftest-async]]
[frontend.test.node-helper :as test-node-helper]
[frontend.fs :as fs]
[promesa.core :as p]
["fs" :as fs-node]
["path" :as node-path]))
(deftest-async create-if-not-exists-creates-correctly
;; dir needs to be an absolute path for fn to work correctly
(let [dir (node-path/resolve (test-node-helper/create-tmp-dir))
some-file (node-path/join dir "something.txt")]
(deftest-async create-if-not-exists-does-not-create-correctly
(let [dir (node-path/resolve (test-node-helper/create-tmp-dir))
some-file (node-path/join dir "something.txt")]
(fs-node/writeFileSync some-file "OLD")
clj-kondo/clj-kondo
(ns clj-kondo.test-test
(:require
[clj-kondo.core :as clj-kondo]
[clj-kondo.test-utils :refer [assert-submaps lint!]]
[clojure.java.io :as io]
[clojure.test :refer [deftest is]]))
(deftest missing-test-assertion-test
(doseq [lang ["clj" "cljs"]]
(let [lint! #(lint! % "--lang" lang)]
(is (empty? (lint! "(ns foo (:require [clojure.test :as t])) (t/deftest foo (t/is (odd? 1)))")))
(is (empty? (lint! "(ns foo (:require [clojure.test :as t])) (t/deftest- foo (t/is (odd? 1)))")))
(assert-submaps
'({:file "<stdin>", :row 1, :col 57, :level :warning, :message "missing test assertion"})
(lint! "(ns foo (:require [clojure.test :as t])) (t/deftest foo (odd? 1))"))
(assert-submaps
'({:file "<stdin>", :row 2, :col 21, :level :warning, :message "missing test assertion"})
(lint! "(ns foo (:require [clojure.test :as t] [clojure.set :as set]))
(t/deftest foo (set/subset? #{1 2} #{1 2 3}))"))
(assert-submaps
'({:file "<stdin>", :row 2, :col 38, :level :warning, :message "missing test assertion"})
(lint! "(ns foo (:require [clojure.test :as t] [clojure.set :as set]))
(t/deftest foo (t/testing \"foo\" (set/subset? #{1 2} #{1 2 3})))"))
(assert-submaps
'({:file "<stdin>", :row 2, :col 49, :level :warning, :message "missing test assertion"})
(lint! "(ns foo (:require [clojure.test :as t] [clojure.set :as set]))
(t/deftest foo (t/testing \"foo\" (let [x 1] (set/subset? #{1 2} #{1 2 3}))))"))
(assert-submaps
'({:file "<stdin>", :row 2, :col 35, :level :warning, :message "missing test assertion"})
(lint! "(ns foo (:require [clojure.test :as t]))
(t/deftest foo (not (= 1 2)))"))
(assert-submaps
[]
(lint! "(ns foo (:require [clojure.test :as t]))
(t/deftest foo (t/testing (str \"foo\" 1 2 3)
(is (not (= 1 2)))))"))
(assert-submaps
[]
(lint! "(require '[clojure.test :refer :all]) (deftest foo (swap! (atom 1) inc))")))))
(deftest deftest-test
(is (empty? (lint! (io/file "corpus" "deftest.cljc")
'{:linters {:unresolved-symbol {:level :error}}}))))
lambdaisland/kaocha
(ns kaocha.private-test
(:require [clojure.test :refer :all]
[kaocha.testable :as testable]))
(deftest- private-test
(is true))
wilkerlucio/pathom
(ns com.wsscode.pathom.diplomat.http.fetch-test
(:require
[clojure.test :refer [is are testing]]
[com.wsscode.async.async-cljs :refer [let-chan <!p go-catch <? <?maybe deftest-async]]
[com.wsscode.pathom.diplomat.http :as p.http]
[com.wsscode.pathom.diplomat.http.fetch :as fetch]
[nubank.workspaces.core :as ws]))
(deftest-async test-request-async
(is (= (<? (fetch/request-async {::p.http/url "data:application/json,{\"json\": \"data\"}"
::p.http/as ::p.http/json}))
{::p.http/status 200
::p.http/body {:json "data"}})))
cloojure/tupelo
; Copyright (c) Alan Thompson. All rights reserved.
; The use and distribution terms for this software are covered by the Eclipse Public
; License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the
; file epl-v10.html at the root of this distribution. By using this software in any
; fashion, you are agreeing to be bound by the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns tupelo.test
"Testing functions."
#?(:cljs (:require-macros [tupelo.test]))
(:require
[tupelo.core :as t]
[tupelo.string :as ts]
[clojure.test :as test]
))
(defmacro ^:deprecated dotest-focus ; #todo README & tests
"Alias for tupelo.test/deftest-focus "
[& body]
(let [test-name-sym (symbol (str "dotest-line-" (:line (meta &form))))]
`(def ~(vary-meta test-name-sym assoc
:test `(fn [] ~@body)
:test-refresh/focus true)
(fn [] (test/test-var (var ~test-name-sym))))))