clojure测试说明

来源:互联网 发布:幼儿园网络培训意义 编辑:程序博客网 时间:2024/06/06 02:50

Clojure测试说明

 

1.      下载eclipse插件以支持clojure:

地址:http://ccw.cgrand.net/updatesite/

下载完成即可算成功

2.      新建leiningen project

如:

3.      新建 lein文件夹 copy jar包 leiningen-2.0.0-preview10-standalone.jar至此文件夹,copy

Lein.bat   此为启动clojure编译环境的脚本

4.      修改project.clj 增加依赖 以支持测试程序 如:

5.      cmd进去此工程目录下 执行lein repl 进去编译环境:

  

端口号 此时为2657. 切换至eclipse    window—》connect to repl

 

会进去编译环境 此时

证实可用

6.      在core.clj 中 引入test依赖即可开始写测试

 

Ctrl+alt+l运行

 

出错:FAIL in (test-say) (core.clj:9)

expected:(= "hello worldss" say)

  actual: (not (="hello worldss" "hello world"))

 

提示此两个字符串不相等 修改

说明测试通过

7.defn 为定义函数的

不带参数(defnm1 [] "hello")

        (m1)

带参数(defn m2 [x] (format "hello%s" x))

(m2 "world")

 

defntest 为测试的

(defntest test-say)

(run-tests) 为运行所有测试

(test-say) 为运行test-say这个测试

 (def v1 10) 为定义值或名称

 (let [x 10] (println x)) 为局部临时变量定义 println为打印函数

(ns) 命名空间

Hhtp请求

(require '[clj-http.client :as client])
(client/get "http://www/baidu.com")

结果:

 

 

 所需工具 下载地址:http://download.csdn.net/detail/zxcvg/4914520

 

原创粉丝点击