Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 在clojure中测试命名空间时出错_Testing_Clojure - Fatal编程技术网

Testing 在clojure中测试命名空间时出错

Testing 在clojure中测试命名空间时出错,testing,clojure,Testing,Clojure,在测试文件中,我要求测试文件如下: (ns calc.alg-spec (:refer-clojure) (:use clojure-test) (:require [calc.alg :as alg])) (deftest silly-test [] (is (= 2 2))) (deftest alg-plus-test [] (is (= (alg/plus 2 2) 4))) (run-all-tests) 问题是第一个测试成功,而第二个测试抛出以下异常:

在测试文件中,我要求测试文件如下:

(ns calc.alg-spec
  (:refer-clojure)
  (:use clojure-test)
  (:require [calc.alg :as alg]))

(deftest silly-test []
  (is (= 2 2)))

(deftest alg-plus-test []
  (is (= (alg/plus 2 2) 4)))

(run-all-tests) 
问题是第一个测试成功,而第二个测试抛出以下异常:

javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial

alg名称空间有什么问题?为什么我不能调用它的函数?

您的代码片段没有问题,问题出在其他地方。如果您还没有这样做,我会使用它,并遵循Leiningen的测试代码惯例。

您的代码片段没有问题,问题出在其他地方。如果您还没有,我会使用Leiningen,并按照Leiningen的约定测试代码。

谢谢您的帮助,我已经使用Leiningen进行测试了,我不知道,有些函数测试得很好,其他函数会抛出这个奇怪的例外。如果可能,请提供有关您的环境和运行Clojure的方式的更多详细信息。答案必须在那里。感谢您的帮助,我已经使用leiningen进行测试了,我不知道,有些函数测试得很好,其他函数抛出了这个奇怪的异常。如果可能,请提供有关您的环境以及您运行Clojure的方式的更多详细信息。答案必须在那里。