构建步骤“执行 Windows 批处理命令”将构建标记为失败完成:失败

Has*_*san 2 java jenkins

我已经将我的项目配置为使用 Jenkins 运行构建,如果我自己执行 testng.xml,它会成功执行我的测试用例,但是如果我通过 Jenkins 执行,我会收到以下错误消息

构建步骤“执行 Windows 批处理命令”将构建标记为失败完成:失败

但是,如果测试用例输出只是使用 `(system.out.println();)

如果测试用例与打开浏览器有关,它会通过 Jenkins 失败

这是我的测试课

    public WebDriver driver;
    public String baseUrl = "http://iparkit.com/";

    @BeforeMethod
      public void initializeWebDriver() {

          driver = new FirefoxDriver();
          driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
          driver.get(baseUrl);
          driver.manage().window().maximize();
      }
    //Close Browser after each test case execution
    @AfterMethod
    public void closeBrowser()
    {
        driver.close();
    }
    @Test(enabled=true) //TC2-01 - OK
    public void iparkit_valid_email_password() throws InterruptedException
    {
        driver.findElement(By.xpath(".//*[@id='mast']/nav/ul/li[4]/a")).click();
        driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("imanltd+1@hotmail.com");
        driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("*******");
        driver.findElement(By.xpath(".//*[@id='top']/div/main/form/main/fieldset[3]/button")).click();
        String Expectedlnktext = driver.findElement(By.linkText("Sign Out")).getText();
        String Actuallnktext = "Sign Out";
        Assert.assertEquals(Actuallnktext,Expectedlnktext);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的 testng.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
  <test name="Test">
    <classes>
       <class name="automationframework.Iparkittesting"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->
Run Code Online (Sandbox Code Playgroud)

这是最后一个控制台输出

Started by user anonymous
Building in workspace D:\K - Selenium\SeleniumWorkspace\iParkit_copy
[iParkit_copy] $ cmd /c call C:\Windows\TEMP\hudson4187523140058494240.bat

D:\K - Selenium\SeleniumWorkspace\iParkit_copy>run.bat

D:\K - Selenium\SeleniumWorkspace\iParkit_copy>java -cp bin;lib/* org.testng.TestNG testng.xml 
[TestNG] Running:
  D:\K - Selenium\SeleniumWorkspace\iParkit_copy\testng.xml


===============================================
Suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)

小智 5

exit /b 0在批处理脚本的末尾使用应该可以解决问题。