如何在多个文件中设置mocha测试用例的执行顺序 [英] How to set execution order of mocha test cases in multiple files
本文介绍了如何在多个文件中设置mocha测试用例的执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个包含mocha测试用例的javascript文件。
I have two javascript files which contain mocha test cases.
//----------abc.js -------------
describe("abc file", function(){
it("test 1" , function(){
assert.equal(20 , 20);
});
});
//---------xyz.js--------------
describe("xyz file", function(){
it("test 1" , function(){
assert.equal(10 , 10);
});
});
我已将它们放在名为 test
当我执行 mocha
命令时,第一个文件(abc.js)总是在xyz.js之前执行。
我认为这可能是由于按字母顺序排列并将文件重命名为
I have put them in a folder called test
and when I execute the mocha
command the first file(abc.js) is always executed before xyz.js.
I thought this might be due to alphabetical ordering and renamed the files as
abc.js => xyz.js
xyz.js => abc.js
但仍然执行xyz.js(以前的abc.js)的内容第一。如何更改这些测试文件的执行顺序?
but still, the content of the xyz.js (previously abc.js) is executed first. How can I change the execution order of these test files?
推荐答案
Mocha有一个 - sort
(短 -S
)选项可对测试文件进行排序:
Mocha has a --sort
(short -S
) option that sorts test files:
$ mocha --help
[...]
-S, --sort sort test files
[...]
这篇关于如何在多个文件中设置mocha测试用例的执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文