gpt4 book ai didi

cucumber - 并行运行时测试会中断

转载 作者:行者123 更新时间:2023-12-02 19:37:20 24 4
gpt4 key购买 nike

当我并行运行功能时(通过在 wdio.conf.js 中将 maxInstances 设置为 2),它们每隔一段时间就会失败,但是当 maxInstances 为 1 时,一切正常。看来这两个测试在并行运行时以某种方式使用彼此的 session 。知道它是什么吗?

一件重要的事情。 Webdriver.io 无法执行断言(因为它们是在不同的 session 上以某种方式进行的),因此对于失败的断言,堆栈跟踪非常简单。

wdio.conf.js

exports.config = {
specs: [
'./features/*.feature'
],
maxInstances: 2,
services: ['selenium-standalone'],
capabilities: [
{ browserName: 'chrome' }
],
baseUrl: 'http://localhost:4000',
framework: 'cucumber',
reporters: ['spec'],
cucumberOpts: {
require: ['./features/steps.js'],
strict: true
}
};

登录功能

Feature: Login page
Scenario: Click on the search link redirects the user
Given the user is on the login route
When the user clicks on the search link
Then he sees the search route

搜索.feature

Feature: Search page
Scenario: Click on the login link redirects the user
Given the user is on the search route
When the user clicks on the login link
Then he sees the login route

steps.js

const { Given, When, Then, Before, After } = require('cucumber');
const { assert } = require('chai');

Given(/^the user is on the login route$/, () => browser.url('/login'));
When(/^the user clicks on the search link$/, () => browser.click('.search-link'));
Then(/^he sees the search route$/, () => assert.equal(browser.isExisting('.search-route'), true));

Given(/^the user is on the search route$/, () => browser.url('/search'));
When(/^the user clicks on the login link$/, () => browser.click('.login-link'));
Then(/^he sees the login route$/, () => assert.equal(browser.isExisting('.login-route'), true));

最佳答案

这是因为我尝试使用浏览器同步为应用程序提供目录服务。当使用任何其他 Web 服务器提供目录时,一切正常。据我了解,这是因为 browser-sync 尝试在打开多个浏览器时同步 url。

关于cucumber - 并行运行时测试会中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52160928/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com