在Testcafe中,如何在多个浏览器上分发测试

问题描述

我有100个测试。 我希望前50个测试在Chrome上运行,然后下50个在Firefox中运行。

我不想对测试名称进行硬编码。

我们有配置这种情况的简便方法吗?

解决方法

您需要以某种方式区分测试。一种简单的方法是使用标签:

test
    .meta({ b: 'firefox' })
    ('Test 1',async t => { 

    // some test steps
});

test
    .meta({ b: 'chrome' })
    ('Test 2',async t => { 

    // some test steps
});

然后您将通过以下方式在firefox中执行某些操作,并在chrome中执行某些操作:

$ testcafe chrome tests/* --test-meta b=chrome && testcafe firefox tests/* --test-meta b=firefox

您也可以使用--fixture-meta。或者,您可以将所有要执行的测试放在某个目录中的某个浏览器中,等等。