How to show all @Test result in the TestNG Report when methods called from another @Test method

I am using Apache POI for Excel Input.

I want to control the method execution from excel instead of creating long TestNG XML files.

Please suggest a way to get all @Test outputs.

I am adding my code here:

public class mainclass extends common.Utility{
public static int Mrownum = 2;
public static String EXLFilePath = System.getProperty(“user.dir”) + “\\TestData\\JumpTest.xlsx”;

@Test
public void runcases() throws Exception {
setExcelFile(EXLFilePath, “Global”);

for (int i = Mrownum; i < (ExcelWS.getLastRowNum() + Mrownum); i++) {
setExcelFile(EXLFilePath, “Global”);
String mname = GetDatafromCell(Mrownum, “ActionName”);
String EF = GetDatafromCell(Mrownum, “ExecutionFlag”);
if (EF.equalsIgnoreCase(“false”)) {
Mrownum = Mrownum + 1;
continue;
}
else {

switch (mname) {
case “p”:
p();
subclassA obA = new subclassA();
obA.runcases();
Mrownum = Mrownum + 1;
break;

case “q”:
q();
subclassB obB = new subclassB();
obB.runcases();
Mrownum = Mrownum + 1;
break;

case “r”:
r();
subclassC obC = new subclassC();
obC.runcases();
Mrownum = Mrownum + 1;
break;

case “XXX”:
System.out.println(“All Iterations Completed”);
Mrownum = Mrownum + 1;
return;

default:
break;
}
}

}

}

@Test
public void p() {
System.out.println(“Executed method – P”);

}

@Test
public void q() {
System.out.println(“Executed method – Q”);
}

@Test
public void r() {
System.out.println(“Executed method – R”);
}

}

 

public class subclassA extends mainclass{
private static int Arownum = 2;

@Test
public void runcases() throws Exception {
setExcelFile(EXLFilePath, “A”);

for (int i = Arownum; i < (ExcelWS.getLastRowNum() + Arownum); i++) {
String Aname = GetDatafromCell(Arownum, “ActionName”);
String AEF = GetDatafromCell(Arownum, “ExecutionFlag”);
if (AEF.equalsIgnoreCase(“false”)) {
Arownum = Arownum + 1;
continue;
}
else {
switch (Aname) {

case “a1”:
a1();
Arownum = Arownum + 1;
break;

case “a2”:
a2();
Arownum = Arownum + 1;
break;

case “a3”:
a3();
Arownum = Arownum + 1;
break;

case “XXX”:
System.out.println(“Sub Class A Iteration Completed”);
Arownum = Arownum + 1;
return;
}
}
}

}

@Test
public void a1() {
System.out.println(“Executed method-A1”);
}

@Test
public void a2() {
System.out.println(“Executed method-A2”);
}

@Test
public void a3() {
System.out.println(“Executed method-A3”);
}

}

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.