put [color=#FF0000:26123vzb]softAssert.AssertAll();[/color:26123vzb]
at the the end @Test.
it will fail the test and move on to @AfterMethod.
or
it will pass the test and move on to @AfterMethod.
either way it will be shown in extent report.
Sorry, I am not getting you. [b:1523obe0]As you say "put softAssert.AssertAll();
at the the end @Test."[/b:1523obe0]---- I already put softAssert.AssertAll(); at the end of @Test in my code. but still Reports are not generate.
[b:1523obe0]Code :[/b:1523obe0]-
package ddf.testCases;
import java.io.IOException;
import java.util.Hashtable;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;
import com.relevantcodes.extentreports.LogStatus;
import ddf.baseTest.BaseTest;
public class DummyTestB extends BaseTest {
//String testCaseName ="TestA";
SoftAssert softAssert;
@Test(dataProvider="Excel_Datprovider")
public void testB(Hashtable<String, String> data) throws IOException{
softAssert=new SoftAssert();
test= rep.startTest("DummyTestB");
test.log(LogStatus.INFO, "Starting the Test,TestB");
/* if(data.get("RunMode").equals("N")){
test.log(LogStatus.SKIP, "Skipping the Test as RunMode is N");
throw new SkipException("Skipping the Test as RunMode is N");
}*/
openBrowser("Mozilla");
test.log(LogStatus.INFO, "Open the browser");
navigate("appUrl");
//Verify signin text on the page
/*if(!verifyTitle("signtitleText_xpath","signinText"))
softAssertion.assertTrue(false, "Title is not matched");*/
softAssert.assertTrue(false, "E1");
softAssert.assertTrue(false, "E2");
softAssert.assertTrue(false, "E3");
softAssert.assertTrue(true, "Test is pass");
//Check that if EmailId is not present
if(!isElementPresent("email_xpath"))
reportFailure("Element is not present");
type("email_id","sambhasin4@gmail.com");
click("btn_Click_xpath");
takeScreenshot();
}
[b:1523obe0]@AfterMethod
public void Quit(){
try{
softAssert.assertAll();
}catch(Exception e){
test.log(LogStatus.FAIL, e.getMessage());
}
rep.endTest(test);
rep.flush();
[/b:1523obe0]
}
@DataProvider
public Object [][]Excel_Datprovider(){
xl = new Xls_Reader("D:\\Data.xlsx");
String testCaseName ="TestB";
String sheetName="Data";
int TestcaseExecuteRowNumber = 1;
while (!xl.getCellData(sheetName, 0, TestcaseExecuteRowNumber).equals(testCaseName))
{
TestcaseExecuteRowNumber++;
}
System.out.println("TestCase is start from -- " +TestcaseExecuteRowNumber);
int colStartRowNumber= TestcaseExecuteRowNumber+1;
int dataStartRowNumber= TestcaseExecuteRowNumber+2;
//Calculate rows of Executed data
int rows=0;
while (!xl.getCellData(sheetName, 0, dataStartRowNumber+rows).equals("")){
rows++;
}
System.out.println("Total row for execution of data are -- " +rows);
//Calculate cols of Executed data
int cols=0;
while(!xl.getCellData(sheetName, cols, colStartRowNumber).equals("")){
cols++;
}
System.out.println("Total columns of exected data are -- " +cols);
//Read the data
Object[][] data= new Object[rows][1];
int rowsCount=0;
Hashtable<String, String> table=null;
for(int rNum=dataStartRowNumber;rNum<dataStartRowNumber+rows;rNum++){
table=new Hashtable<String,String>();
for(int cNum=0;cNum<cols;cNum++){
String key= xl.getCellData(sheetName, cNum, colStartRowNumber);
String value=xl.getCellData(sheetName, cNum, rNum);
table.put(key, value);
}
data[rowsCount][0]= table;
rowsCount++;
}
return data;
}
}
[code:1i56ik3h]@Test(dataProvider="Excel_Datprovider")
public void testB(Hashtable<String, String> data) throws IOException{
softAssert=new SoftAssert();
test= rep.startTest("DummyTestB");
test.log(LogStatus.INFO, "Starting the Test,TestB");
/* if(data.get("RunMode").equals("N")){
test.log(LogStatus.SKIP, "Skipping the Test as RunMode is N");
throw new SkipException("Skipping the Test as RunMode is N");
}*/
openBrowser("Mozilla");
test.log(LogStatus.INFO, "Open the browser");
navigate("appUrl");
//Verify signin text on the page
/*if(!verifyTitle("signtitleText_xpath","signinText"))
softAssertion.assertTrue(false, "Title is not matched");*/
softAssert.assertTrue(false, "E1");
softAssert.assertTrue(false, "E2");
softAssert.assertTrue(false, "E3");
softAssert.assertTrue(true, "Test is pass");
//Check that if EmailId is not present
if(!isElementPresent("email_xpath"))
reportFailure("Element is not present");
type("email_id","sambhasin4@gmail.com");
click("btn_Click_xpath");
takeScreenshot();
softAssert.assertAll();
}
@AfterMethod
public void Quit(){
rep.endTest(test);
rep.flush();
}
[/code:1i56ik3h]