测试套件模块,用以定义管理测试套件
引用方法:
var test = require('test');
| Type | Method and Description |
|---|---|
| const | public const BDDBDDBDD定义 BDD(Behavior Drive Development) 测试环境,支持 describe, xdescribe, it, xit, before, after, beforeEach 和 afterEach,同时初始化 assert 和expect |
| const | public const TDDTDDTDD定义 TDD(Test Drive Development) 测试环境,支持 suite, xsuite, test, xtest, setup, teardown, suiteSetup 和 suiteTeardown,同时初始化 assert 和expect |
| void | public static static assertassertassert断言测试模块,如果测试值为假,则报错,报错行为可设定继续运行或者错误抛出 |
| Integer | public static Integer slowslowslow设置和查询慢速测试警告阀值,以 ms 为单位,缺省为 75 |
| Type | Method and Description |
|---|---|
| void | describe(String name,Function block)定义一个测试模块,可嵌套定义 |
| void | xdescribe(String name,Function block)停止测试的模块定义 |
| void | it(String name,Function block)定义一个测试项目 |
| void | xit(String name,Function block)禁止测试的项目定义 |
| void | before(Function func)定义当前测试模块进入事件 |
| void | after(Function func)定义当前测试模块退出事件 |
| void | beforeEach(Function func)定义当前测试模块测试项目进入事件 |
| void | afterEach(Function func)定义当前测试模块测试项目退出事件 |
| Integer | run(Integer loglevel)开始执行定义的测试模块 |
| Expect | expect(Value actual,String msg)expect 语法测试引擎 |
| void | setup(Integer mode)初始化当前脚本的测试环境,将 test 模块方法复制为当前脚本全局变量 |
public const BDDBDDBDD定义 BDD(Behavior Drive Development) 测试环境,支持 describe, xdescribe, it, xit, before, after, beforeEach 和 afterEach,同时初始化 assert 和expect
public const TDDTDDTDD定义 TDD(Test Drive Development) 测试环境,支持 suite, xsuite, test, xtest, setup, teardown, suiteSetup 和 suiteTeardown,同时初始化 assert 和expect
public static static assertassertassert断言测试模块,如果测试值为假,则报错,报错行为可设定继续运行或者错误抛出
public static Integer slowslowslow设置和查询慢速测试警告阀值,以 ms 为单位,缺省为 75
describe(String name,Function block)定义一个测试模块,可嵌套定义
name 定义模块名称
block 模块初始化代码
xdescribe(String name,Function block)停止测试的模块定义
name 定义模块名称
block 模块初始化代码
it(String name,Function block)定义一个测试项目
name 定义项目名称
block 测试内容
xit(String name,Function block)禁止测试的项目定义
name 定义项目名称
block 测试内容
before(Function func)定义当前测试模块进入事件
func 事件函数after(Function func)定义当前测试模块退出事件
func 事件函数beforeEach(Function func)定义当前测试模块测试项目进入事件
func 事件函数afterEach(Function func)定义当前测试模块测试项目退出事件
func 事件函数run(Integer loglevel)开始执行定义的测试模块
loglevel 指定进行测试时的日志输出级别,ERROR 时,项目报错信息集中在报告后显示,低于 ERROR 时,输出信息随时显示,高于 ERROR 时,只显示报告返回测试用例统计结果,正确则返回 0,错误则返回错误个数
expect(Value actual,String msg)expect 语法测试引擎
actual 指定要测试的数值
msg 断言失败时的提示信息
返回 Expect 对象用以链式调用
setup(Integer mode)初始化当前脚本的测试环境,将 test 模块方法复制为当前脚本全局变量
mode 指定初始化的模式,缺省为 BDD