有没有办法向测试用例添加标签,以便我可以运行特定的测试用例而不是运行整个套件?如果是,有人可以帮我怎么做吗?
例如。
describe("User Service - create and search user", function() {
var data;
parseData('/Users/ksachdeva/node_modules/chakram/ns/tests/user-service/requestBodies/createUser.csv', execute);
function execute(data) {
before('should create a user', function () {
res = call.post(testConfig.APP_URL + testConfig.CREATE_USER, JSON.parse(data));
return expect(res).to.have.json(function(json) {
userid = json.user.userid;
console.log("API Response ----> " + JSON.stringify(json));
});
});
});
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢!
摩卡标签的想法在这个 WIKI 页面中有很好的描述。
主要思想是在测试中(即在父describe块中)使用特定关键字,然后使用过滤选项 ( grep) 仅运行这些测试。
这是摩卡选项的完整列表。
从 CLI 您可以执行以下操作:
$ mocha --grep <pattern>
Run Code Online (Sandbox Code Playgroud)
或者
$ mocha -g <pattern>
Run Code Online (Sandbox Code Playgroud)
通过编程,您可以执行以下操作:
// Instantiate a Mocha instance.
var mocha = new Mocha({
grep: <String|RegExp>
});
mocha.addFile( 'test.js' );
mocha.run();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9448 次 |
| 最近记录: |