cucumber - 测试在并行运行时中断
问题描述
当我并行运行功能时(通过设置maxInstances
为2
in wdio.conf.js
),它们每隔一次都会失败,但是当maxInstances
is时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
}
};
登录功能
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: 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
步骤.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。
推荐阅读
- android - gridview.extent 不会在颤动中滚动
- sql - 在脚本中重用相同的 sql 子句
- javascript - 如何按一个参数升序调用方法?
- angular - 无法理解这个错误(GET http://makeappdev.xyz/1e6ab715a3a95d4603.js net::ERR_NAME_NOT_RESOLVED)
- javascript - 将客户端时间设置为服务器时间并实时更新
- android - 内联函数导致单元测试代码覆盖率报告出错
- python - 使用 For-Else 会执行这两个条件。我该如何解决?
- c - 为什么我们在函数名上使用 & 符号?
- java - 无法理解何时必须将 return 语句与递归关联使用
- javascript - 如何使用或不使用javascript在数字之间添加垂直线?