+ Start a Discussion
veeru417veeru417 

Need Help in writing Testclass for Wrapperclass Code coverage is 70% help me to pass testcoverage..

Hi every one ,

 

I have started working my first testclass,This class containing wrapper class (innerclass).I tried to write the test class but some part of code is not covered.I am posting my class n testclass can any one help me pls

 

Below is my Original Class

 

In the below class the parts of code not covered are

//Parts of code not covered in Testcoverage 
 public List<TestCaseLogsClass> gettestlog12(){
      return TestCaseLogsClassList;
  }

//this part of code is for rendering table in VF page
public boolean getIsRender(){
                if(TestCaseLogsClassList.size()>0){
                isRender = true;
        }
        else{
                isRender = false;
        }
//This is in wrapper class deleteTestCaseLog()
for(Integer deleteSpecifier=0;deleteSpecifier<TestCaseLogsClassList.size();deleteSpecifier++){
            	if(delcsDetId == TestCaseLogsClassList[deleteSpecifier].deleteID){
                	TestCaseLogsClassList.remove(deleteSpecifier);
                     break;
                }

 

 

//Class
public with sharing class TestClass { public boolean isRender = false; public integer deleteSpecifier=0; public Test_Case_Log__c testLog{get;set;} public List<TestCaseLogsClass> gettestlog12(){ return TestCaseLogsClassList; } public List<Test_Case_Log__c> testCaseLogList = new List<Test_Case_Log__c>(); public TestClass(ApexPages.StandardController controller) { testLog = (Test_Case_Log__c)Controller.getRecord(); } public boolean getIsRender(){ if(TestCaseLogsClassList.size()>0){ isRender = true; } else{ isRender = false; } return isRender; } public void add(){ deleteSpecifier = deleteSpecifier+1; TestCaseLogsClassList.add(new TestCaseLogsClass(testLog,deleteSpecifier)); testLog = new Test_Case_Log__c(); } public pagereference save1(){ for(Integer i=0;i<TestCaseLogsClassList.size();i++){ testCaseLogList.add(TestCaseLogsClassList[i].objTestCaseLog); } if(testCaseLogList.size()>0){ insert testCaseLogList; PageReference pageRef = new PageReference('/a02/o'); return pageRef; } return null; } public void deleteTestCaseLog(){ Integer delcsDetId = Integer.valueOf(System.currentPageReference().getParameters().get('delcsDetId')); for(Integer deleteSpecifier=0;deleteSpecifier<TestCaseLogsClassList.size();deleteSpecifier++){ if(delcsDetId == TestCaseLogsClassList[deleteSpecifier].deleteID){ TestCaseLogsClassList.remove(deleteSpecifier); break; } } } public List<TestCaseLogsClass> TestCaseLogsClassList = new List<TestCaseLogsClass>(); public class TestCaseLogsClass { public Test_Case_Log__c objTestCaseLog{get;set;} public Integer deleteID{get;set;} public TestCaseLogsClass(Test_Case_Log__c objTestCaseLog1,Integer deleteID1){ deleteID = deleteID1; objTestCaseLog = objTestCaseLog1; } } }

 

This is my TestClass for above class

@isTest
private class TestClassTest {

    static testMethod void myUnitTest() {
    	
    	Test_Cases__c testTestcases=new Test_Cases__c(name='testcase1');
    	insert testTestcases;
    	ApexPages.StandardController sc1 = new ApexPages.StandardController(new Test_Case_Log__c());
    	TestClass test1=new Testclass(sc1);
    	test1.save1();
    	ApexPages.StandardController sc = new ApexPages.StandardController(new Test_Case_Log__c(Test_Cases__c=testTestcases.ID));
    	TestClass test=new Testclass(sc);
    	
    	test.add();
    	test.save1();
    	test.deleteTestCaseLog();
    	test.gettestlog12();
    	test.isRender=true;
    	test.getIsRender();
    	test.isRender=false;
    	test.getIsRender();
    	
    	
    	
    	
        
    }
}

 Thanks in advance

 

 

Regards,

Veeru

 

colemabcolemab

Please edit your orignal post and highlight (in red) the lines of code that are not getting code coverage.