Jenkins版本无法启动黄瓜TESTS并超时

时间:2019-04-30 10:28:34

标签: jenkins testing build cucumber

我是詹金斯的新手。我的基本Jenkins配置在命令行中早就可以很好地工作了,但是由于我确实报告了配置,因此TESTS不再从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"));
    }
}

编辑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 stepDefinition

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失败

1 个答案:

答案 0 :(得分:1)

在寻找解决方案之后。我发现Jenkins作为Windows服务安装在我的计算机上,并且禁用了允许交互的Jenkins登录属性。所以我,

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

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