简体   繁体   English

将 mocha 并行选项与动态生成的 Mocha 测试套件一起使用

[英]Using mocha parallel option with dynamically generated Mocha test suite

I have some sample Mocha codes as below:我有一些示例摩卡代码如下:

 function runMochaTestSuite(testSuite) { describe(testSuite.name, function () { for (testCase of testSuite.testCases) { it(testCase.name, function () { }); } }); } const myTestSuites = [ { name: "Test Suite 1", testCases: [ { name: "Test Case 1-1", }, { name: "Test Case 1-2", }, ], }, { name: "Test Suite 2", testCases: [ { name: "Test Case 2-1", }, { name: "Test Case 2-2", }, ], }, ]; for (suite of myTestSuites) { runMochaTestSuite(suite); }

I run this ok with Mocha version 7.我使用 Mocha 版本 7 运行正常。

how can I make use of new parallel option in version 8 to run the test suites like above in parallel?如何利用版本 8 中的新并行选项并行运行上述测试套件?

Much appreciated for your help.非常感谢您的帮助。 Thank you in advance.先感谢您。

You can't.你不能。

The documentation says:文档说:

Use the --parallel flag to run tests in a worker pool.使用 --parallel 标志在工作池中运行测试。 Each test file will be put into a queue and executed as workers become available.每个测试文件都将被放入一个队列中,并在工作人员可用时执行。

The parallel execution is file based, not single test based.并行执行是基于文件的,而不是基于单个测试的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM