测试在 运行 并行时中断
Tests break when they are running in parallel
当我 运行 特征并行时(通过在 wdio.conf.js
中将 maxInstances
设置为 2
)它们每隔一段时间就会失败,但是当 maxInstances
是1
,一切正常。似乎这两个测试在 运行 并行时以某种方式相互使用会话。知道它是什么吗?
一件重要的事情。 Webdriver.io
无法执行断言(因为它们以某种方式在不同的会话上进行),因此堆栈跟踪对于失败的断言非常简单。
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
}
};
login.feature
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
search.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));
这是因为我试图通过使用 browser-sync
的应用程序提供目录。当使用任何其他 Web 服务器提供目录时,一切正常。据我了解,这是因为 browser-sync
尝试在打开多个浏览器时同步 url。
请问这个browser-sync具体用在什么地方。当 运行 并行时,即使顺序 运行 成功,我的测试用例也会失败。
奇怪的是,我观察到最小化浏览器中的测试用例失败,而处于 maximize/normal 状态的测试用例通过。
修改此 browser-sync 可能会解决此问题,但我不确定在哪里可以找到 browser-sync 代码。它绝对不是 package.json 和配置文件
的一部分
当我 运行 特征并行时(通过在 wdio.conf.js
中将 maxInstances
设置为 2
)它们每隔一段时间就会失败,但是当 maxInstances
是1
,一切正常。似乎这两个测试在 运行 并行时以某种方式相互使用会话。知道它是什么吗?
一件重要的事情。 Webdriver.io
无法执行断言(因为它们以某种方式在不同的会话上进行),因此堆栈跟踪对于失败的断言非常简单。
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
}
};
login.feature
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
search.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));
这是因为我试图通过使用 browser-sync
的应用程序提供目录。当使用任何其他 Web 服务器提供目录时,一切正常。据我了解,这是因为 browser-sync
尝试在打开多个浏览器时同步 url。
请问这个browser-sync具体用在什么地方。当 运行 并行时,即使顺序 运行 成功,我的测试用例也会失败。
奇怪的是,我观察到最小化浏览器中的测试用例失败,而处于 maximize/normal 状态的测试用例通过。
修改此 browser-sync 可能会解决此问题,但我不确定在哪里可以找到 browser-sync 代码。它绝对不是 package.json 和配置文件
的一部分