[英]How can I run same test concurrently in testcafe to create a race condition?
我正在嘗試創建一個競爭條件,其中相同的測試將同時運行
如果使用testcafe
命令運行測試,可以使用--concurrency
選項。 如果您使用runner
,您可以使用同名方法設置並發,或者只創建幾個runner
對象並使用Promise.race
run
它們:
const createTestCafe = require('testcafe');
async function runTest(testcafe, src) {
const runner = testcafe.createRunner();
const failed = await runner
.src(src)
.browsers('chrome')
.run();
console.log('Tests failed: ' + failed);
}
(async function () {
const testcafe = await createTestCafe('localhost', 1337, 1338);
try {
await Promise.race([
runTest(testcafe, './test1.js'),
runTest(testcafe, './test2.js'),
runTest(testcafe, './test3.js'),
])
}
finally {
await testcafe.close();
}
})()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.