You need to create the object of Xls_Reader only when its required , that is at run time and not at compile time.
If you keep it at global before each test case then this will cause objects to be created for all class before it starts.
Let me know if you want the code i will add it here
I have fixed this issue and i tested with more than 2k sample test cases it will just take 3-4 seconds to start execution
Hi Mohammed,
Could you please add code here it will be very helpful for me to understand
Thanks
Instructor
Ashish Thakur Replied on 11/10/2018
Mohammed,
Can you give the code
Hi All,
Sure will share the code , I would like to know where the GC overload limit is faced i updated the code for eclipse first then I got the same in jenkins
So after updating it finally its working
Please find the updates below hope it helps.
@vijjii - can you please let me know where you found the GC overload , was it in jenkins or in eclipse while running your test suite.?
Hi Vijjii,
Let me explain in detail
In Ashish thakur framework he is creating the object of the XLS_Reader and passing in the data provider, so if you want to make sure GC overhead is not faced do the following
Do not create the object of the XLS_Reader in each class at global level or in the Base class (Just avoid creating the object) this helped me
Test case will look like
public class TC_0001_CP_identifications_Verify_PageTitle extends TestBase {
DataUtil dataUtil = new DataUtil();
String testName = "TC_0001_CP_identifications_Verify_PageTitle";
@DataProvider
public Object[][] getDataForTestCaseName() throws FileNotFoundException {
return dataUtil.getDataForTestCaseName(ConstantValues.DATA_XLS_PATH_PORTAL, testName); // here we will pass the path of the XLS_Reader instead of object.
}
I changed the methods in DataUtil class from static to nonstatic
Step 2: In data util class create the object of xls like given below
public class DataUtil{
static Xls_Reader xls =null; // global object kept to null
public Object[][] getDataForTestCaseName(String excelLocation, String testCaseName) throws FileNotFoundException {
Object[][] data = null;
Xls_Reader xls = new Xls_Reader(excelLocation);
String sheetName = ConstantValues.TESTDATA_SHEET;
Also for other methods use
public boolean isTestExecutable(String excelLocation, String testCaseName) {
xls = new Xls_Reader(excelLocation);
//***********************************************************************************************
IF you cannot understand or do not have time to modify all the scripts then just create the object of the XLS_Reader in the Base as static and extend the base class to all other classes this is temporary fix
public static Xls_Reader xls_chbackoffice = new Xls_Reader(ConstantValues.DATA_XLS_PATH_CHBACKOFFICE);
I have tried both the ways and this works , there is no issue or bug in the XLS_Reader Class its only how we create the object of it and at what point.
Hi Mohammed ,
Thank a lot for sharing the code.
I faced the GC overload exceeded memory issue in Jenkins first and build was failed due to memory error. When I tried to execute the same scripts in eclipse for debugging and found the same issue there as well. Then i increased the heap size as by issuing below command as temporary fix
Xms1024M -Xmx2048M
Thanks ashish
Hi mohammed,
I 'd like to say thanks a lot again. Because the solution which u provided really helped a lot to fix the fc memory issue .
My pleasure.
Instructor
Ashish Thakur Replied on 16/10/2018
Thanks Mohammed for help
Regards
Ashish