【发布时间】:2019-05-03 03:35:16
【问题描述】:
我正在使用黄瓜量角器框架来运行功能文件。
在我的 config.js 中,我有:
specs: [
"../../features/XXX1.feature",
"../../features/XXX2.feature",
...
"../../features/XXXn.feature",
],
cucumberOpts: {
tags: "@mytag",
},
在我的功能文件 XXX1.feature 中,我设置了这个标签“@mytag”:
@mytag
Scenario Outline: my Flow
Given I am running test case one
....
但不在任何其他功能文件中,如 XXX2.feature、XXX3.feature 等。
我希望量角器仅运行 XXX1.feature,而不运行 XXX2.feature。确实如此,当涉及到 XXX2.feature 时,它启动浏览器,什么也不做,然后输出以下内容:
[14:35:53] I/testLogger - [chrome #01-2] PID: 14272
[chrome #01-2] Specs: D:\ptfbc\ui\features\XXX2.feature
[chrome #01-2]
[chrome #01-2] [14:35:44] I/hosted - Using the selenium server at http://127.0.0.1:4444/wd/hub
[chrome #01-2]
[chrome #01-2]
[chrome #01-2] 0 scenarios
[chrome #01-2] 0 steps
[chrome #01-2] 0m00.000s
但它仍然不够好。由于 XXX2.feature 中没有标签“@mytag”。它不应该跳过功能文件 XXX2.feature 并且根本不启动浏览器吗?
为每个没有“@mytag”的不合格功能文件启动浏览器也很耗时。
有没有可以避免这种情况的配置方式?
编辑
功能和 hook.ts
capabilities: {
browserName: "chrome",
shardTestFiles: true,
maxInstances: 1,
'chromeOptions': {
'args': [
'disable-infobars'//,'headless=true','disable-gpu=true',
],
'prefs': {
'credentials_enable_service': false,
'download': {
'prompt_for_download': false,
'directory_upgrade': true,
}
}
}
},
const { BeforeAll, After, Status } = require("cucumber");
import * as fs from "fs";
import { browser } from "protractor";
import { config } from "../config/config";
BeforeAll({timeout: 300 * 1000}, async () => {
await browser.get(config.baseUrl);
});
After(async function(scenario) {
// screenShot is a base-64 encoded PNG
const screenShot = await browser.takeScreenshot();
this.attach(screenShot, "image/png");
});
【问题讨论】:
-
你把启动浏览器的代码放在哪里了?如果 beforeAll 钩子中有它的代码,那可能就是原因。
-
你能把你的钩子代码贴在这里
-
您是否使用过
shardTestFiles: true和maxInstances: <greater than 1>,请在您的量角器conf.js 中发布capabilities和multiCapabilities(如果已设置) -
@yong 是的,我确实使用了 shardTestFiles 和 maxInstances,maxInstances 为 1
-
@KyleFairns 嗨,凯尔,请查看我的更新。 beforeAll 只是在做一个 browser.get()。但我的问题是,如果功能文件没有要运行的标签,应该完全跳过它,甚至不运行 beforeAll
标签: protractor cucumberjs