jasmine generator
jasmine generator 是什么?
这是一款根据注释自动生成 jasmine 用例的工具, 可以帮你节省书写用例的时间, 目前支持生成 html 文件或者 js 文件.
使用条件:
- js 注释遵循 jsdoc 规则;
- 本地安装 python 2.4 以上版本;
使用方法:
js 注释中增添了 @spec 标记, 支持两种用例定义方法:
简单模式:
可以将 example 和用例结合使用, example 就是用例:
/** * simple method * @param { String } str a string charactor * @return { String } result * @spec simple * @example * Test.simple('hehe'); => 'HEHE' */复杂模式:
可能简单模式会影响 jsdoc 中 example 的输出, 这时可以将用例单独书写:
/** * complex method * @param { String } json json string * @return { Object } * @example: * Test.complex('{"a":"b", "c":"d"}'); => {"a": "b", "c": "d"} * @spec complex1 * var ret1 = Test.complex('{"a":"b", "c":"d"}'); * ret1['a'] => 'b' * ret1['c'] => 'd' * @spec complex2 * var ret2 = Test.complex('{"e":"f"}'); * ret2['e'] => 'f' */
其中 => 前边为要检测的语句, 后边为预期的结果.
windows:
修改 run.bat 文件中参数:
python create.py root="js" out="case" template="template.html"其中 root 为需要生成用例的 js 文件夹, out 为输出用例的文件夹, template 为用例模板.
运行 run.bat 文件, 或者直接在命令行下运行以上命令.
ubuntu:
命令行下运行:
python create.py root="js" out="case" template="template.html"
欢迎大家试用并提出宝贵意见, 谢谢大家, 点击下载.
这篇文章发布于 2011年06月11日,星期六,20:51,归类于 编码。 您可以跟踪这篇文章的评论通过 RSS 2.0 feed。 您可以留下评论,或者从您的站点trackback。