我已经阅读了很多文档、文章和文章,据说在一个功能文件中并行运行场景的开箱即用的解决方案是不可能的。我们可以使用maven-surefire-plugin在并行不同的特性文件中运行,但不能使用场景。
例如,有一个带有场景的特性文件:
Feature: Parallel Scenarios
Scenario: First
...
Scenario: Second
...
Scenario: Third
...我想在分离的线程中同时运行所有这些场景。
我怎样才能做到这一点?
发布于 2022-02-15 20:50:29
我使用testNG和courgette-jvm在场景级运行并行测试。这是runner文件
import courgette.api.CourgetteOptions;
import courgette.api.CourgetteRunLevel;
import courgette.api.CucumberOptions;
import courgette.api.testng.TestNGCourgette;
import org.testng.annotations.Test;
@Test
@CourgetteOptions(
threads = 10,
runLevel = CourgetteRunLevel.SCENARIO,
rerunFailedScenarios = true,
rerunAttempts = 1,
showTestOutput = true,
reportTitle = "Courgette-JVM Example",
reportTargetDir = "build",
environmentInfo = "browser=chrome; git_branch=master",
cucumberOptions = @CucumberOptions(
features = "src/test/resources/com/test/",
glue = "com.test.stepdefs",
publish = true,
plugin = {
"pretty",
"json:target/cucumber-report/cucumber.json",
"html:target/cucumber-report/cucumber.html"}
))
class AcceptanceIT extends TestNGCourgette {
}然后使用常规webdriver,我使用RemoteWebDriver
protected RemoteWebDriver createDriver() throws MalformedURLException {
//wherever grid hub is pointing. it should work without grid too
String hubURL = "http://localhost:xxxx/wd/hub";
ChromeOptions options = new ChromeOptions();
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
return (RemoteWebDriver) (driver = new RemoteWebDriver(new URL(hubURL), capabilities));
}
public RemoteWebDriver getDriver() throws MalformedURLException {
if (driver == null) {
this.createDriver();
}
return (RemoteWebDriver) driver;
}您可能必须利用这些依赖关系。
<dependency>
<groupId>io.github.prashant-ramcharan</groupId>
<artifactId>courgette-jvm</artifactId>
<version>5.11.0</version>
</dependency>
<dependency>
<!-- httpclient dpendendecy is to resolve courgette-jvm error - NoClassDefFoundError: org/apache/http/conn/ssl/TrustAllStrategy -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.10</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>6.9.1</version>
</dependency>发布于 2022-12-04 21:46:30
例如,两个测试框架具有并行执行和“Allure”屏幕截图(当步骤失败时)。自述中关于github的所有详细资料:
https://github.com/simileyskiy/cucumber7-selenium3.selenide5-junit5-Allure-parallelExecution
https://github.com/simileyskiy/cucumber7-selenium4.selenide6-junit5-Allure-parallelExecution
https://stackoverflow.com/questions/71020032
复制相似问题