在testcafe中的其他跑步者的主要跑步者?

时间:2019-09-23 19:06:11

标签: testing automated-tests e2e-testing testcafe web-testing

我有几个跑步者正在使用promise.race在特定时间完成测试用例 假设我有Runner1.js,Runner2.js,Runner3.js,如何创建主跑步者,以便可以同时运行所有这些跑步者?

const createTestCafe = require('testcafe');
let testcafe = null;

// createTestCafe('localhost', 1337, 1338)
createTestCafe()
    .then(tc => {
        testcafe     = tc;
         //create test runner for configuring and launching test tasks
        const runner = testcafe.createRunner();



    return runner
        //run test from specified folders/files
        .src(['*the path to all runner.js*'])
        //configure the test runner to run tests in the specified browsers
        .browsers('chrome')
        .reporter('html-testrail')
        .run({skipJsErrors:true})             




    })


           .catch(failedCount => {
               console.log('Tests failed: ' + failedCount);
                testcafe.close();
            })

it's not working this way, any suggestions?

1 个答案:

答案 0 :(得分:2)

TestCafe允许同时运行多个测试运行程序。检查以下代码:

const createTestCafe = require('testcafe');

(async () => {
    const testCafe = await createTestCafe();

    const runner1 = testCafe
        .createRunner()
        .src('test1.js')
        .reporter([{ name: 'spec', output: 'report1.txt' }])
        .browsers('chrome');

    const runner2 = testCafe
        .createRunner()
        .src('test2.js')
        .reporter([{ name: 'spec', output: 'report2.txt' }])
        .browsers('firefox');

    await Promise.all([runner1, runner2].map(runner => runner.run()));

    await testCafe.close();
})();