Fail a test in Extent Report when prg stopped unexpectedly | Selenium Forum
M
Posted on 19/10/2016
package com.inmar.project.testcases;

import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

import com.inmar.project.basePackage.Base;
import com.relevantcodes.extentreports.LogStatus;

public class Login extends Base{


@Test
public void loginTest()
{
test=rep.startTest("Login");

test.log(LogStatus.INFO, " Starting the Test-- Login");
init();
openBrowser();
test.log(LogStatus.INFO, "Browser Opened");
naviagte(prop.getProperty("appurl"));
alert();
test.log(LogStatus.INFO, "Navigated to the URL");
doLogin("username_name","password_name");
test.log(LogStatus.INFO, "Login Successfull");
readText("homepageText_xpath",prop.getProperty("homepageText"));

}

@AfterMethod
public void quit()
{
rep.endTest(test);
rep.flush();
}

}

-------------------------------------------------------------------------------
In the above program, Exception is thrown at the step "alert();". Console shows the exception :"org.openqa.selenium.NoSuchElementException: no such element"
But Extent Report show the test status as Pass.

Here in the above program, we have few more steps to be executed but program stopped accidentally but still the report shows the test cases is Pass.

Please let me know how to fail a test case in Extent Report when the program (test case) stopped unexpectedly.

Thanks,
Kannan C

How do I fail the test cases, if it is not fully run.

M
Replied on 19/10/2016

put a print statement in @AfterMethod and check if it executes.


M
Replied on 19/10/2016

Yes, it is printing the statement in the console.

Responsive image

M
Replied on 20/10/2016

zip and send me the project.


M
Replied on 20/10/2016

I zipped and try to upload. It is keep on processing and the upload is not completed . The file size is 11mb. Original size is 66mb.


M
Replied on 21/10/2016

upload it to google drive and share with me at qtpselenium.supp0rt@gmail.com