gpt4 book ai didi

Jenkins 构建无法启动 cucumber 测试并超时

转载 作者:行者123 更新时间:2023-11-28 21:17:13 25 4
gpt4 key购买 nike

我是 Jenkins 的新手。我的基本 Jenkins 配置确实在早期从命令行运行得很好,但由于我确实报告了配置,所以测试不再从 Jenkins 启动。我安装了“电子邮件扩展”和“电子邮件扩展模板”插件,这些插件开始导致下面的问题(已解释),但我现在已删除它们,但问题仍然存在。

我在最后一行(下方)下方看到纺车,但没有任何反应。

[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cucumber.CucumberRunner
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8791
Only local connections are allowed.

一段时间(18-20 分钟)后,构建超时并显示“无法实例化类 stepDefinitions.LoginSUT”。

[INFO] 
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running cucumber.CucumberRunner
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8791
Only local connections are allowed.
[1556614819.067][SEVERE]: Timed out receiving message from renderer: 600.000
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 8470
Only local connections are allowed.
[1556615421.440][SEVERE]: Timed out receiving message from renderer: 600.000
Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) on port 10001
Only local connections are allowed.
[1556616023.903][SEVERE]: Timed out receiving message from renderer: 600.000
7 Scenarios (7 failed)
28 Steps (7 failed, 21 skipped)
30m7.588s

这是 Jenkins 测试结果的快照。好像有什么东西挡住了它,但我一直没弄明白。任何建议将不胜感激。 enter image description here

我的 CucumberRunner.java 类

//always run this as part of the cucumber class
@RunWith(Cucumber.class)

// additional options for this cucumber class
@CucumberOptions(
features = { // "src/test/resources/features/WebCorporateJourney.feature"//,
"src/test/resources/features/WebRetailJourney.feature" },
glue = { "stepDefinitions" },
plugin = {"com.cucumber.listener.ExtentCucumberFormatter:target/cucumber-reports/report.html" },
monochrome = true)

// bridges between feature file and step definition and help them talk to each
public class CucumberRunner {
@AfterClass
public static void writeExtentReport() {
Reporter.loadXMLConfig(new File("config/report.xml"));
}
}

Edit-1:按要求添加代码

我的 AbstractDriver.Java 类

public class AbstractDriver {

protected static WebDriver driver;

protected WebDriver getDriver() {
// System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// if driver hasn't instantiated then instantiate it
if (driver == null) {
// instantiates the driver
driver = new ChromeDriver();
// driver = new FirefoxDriver();

}
// returns same instance of the driver
return driver;
}
}

我的 LoginSUT.java 步骤定义

public class LoginSUT extends AbstractDriver {

WebDriver driver = getDriver();

@Given("^user is on website$")
public void user_is_on_website() throws Throwable {
// passing admin credentials
driver.get("http://admin:test@mySUTlink.com/");
}

@When("^user enters credentials$")
public void when_user_enters_credentials() throws Throwable {
// Maximising the Browser window
driver.manage().window().maximize();

// Accepting Cookies
driver.findElement(By.xpath("//*[text()='Accept']")).click();

}

@Then("^user is logged on$")
public void user_is_logged_on() throws Throwable {

boolean isDisplayed = driver.findElement(By.xpath("//*[text()='my text to verify']")).isDisplayed();
if (isDisplayed) {
System.out.println("");
System.out.println("USER VERIFICATION: User logged on successfully");
} else {
System.out.println("USER VERIFICATION: User failed to logon");
}
}
}

Edit-2:来自命令行的测试有效,但通过 Jenkins 失败

最佳答案

四处寻找解决方案后。我发现 Jenkins 作为 Windows 服务安装在我的机器上,允许交互的 Jenkins 登录属性被禁用。所以我,

打开服务 -> 查找 Jenkins -> 右键单击​​属性 -> 在“登录”选项卡下勾选方框允许服务与桌面交互

此更改启动了我的 Cucumber 测试,我能够在“控制台输出”下查看正在运行的测试

关于Jenkins 构建无法启动 cucumber 测试并超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55918990/

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