Hassan
Hassan

Reputation: 313

Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE

I've configured my project to run the Build with Jenkins if I execute the testng.xml on my own it successfully execute my test case but if I execute via Jenkins I get the following error message

Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE

However it execute the build successfully if test case output is just using `(system.out.println();)

if test case relates to opening of browsers it gets failed via Jenkins

This is my test class

    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("[email protected]");
        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);
    }
}

and here is my 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 -->

here is last console output

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

Upvotes: 3

Views: 28168

Answers (2)

RicoPuerto
RicoPuerto

Reputation: 91

Using exit /b 0 at the end of the batch script should do the trick.

Upvotes: 9

Timmy Brolin
Timmy Brolin

Reputation: 1181

The batch command will examine the "error level" of the last command (return code). Anything but zero will result in failure. You don't give much details, but it seems your browser returns a non-zero error level.

You could run a dummy command after the browser to chance the error level. Or fix whatever reason is causing the non-zero error level (recommended solution)

Example of a popular dummy command to set the error level is "ver > nul"

Upvotes: 0

Related Questions