+ Start a Discussion
Manjunath reddy 25Manjunath reddy 25 

How do we write a test class for the below class.

Need help in writing test class for the below class


public  class GSDAccountteammembercontroller {

public list<HPE_Account_Team__c> listofrecords{get;set;}
public Boolean displayBOMPopUp {get;set;}
public Boolean TabToBeClosed {get;set;}
    
public PageReference SaveRecords() 
{
system.debug('Method Entry');
    //Id parentrecordid = ApexPages.currentPage().getParameters().get('Id');
    Id parentrecordid = '001G000001IgfGZ';
    list<HPE_Account_Team__c> insertlist = new list<HPE_Account_Team__c>();  
    system.debug('After the Method Entry');
    for(HPE_Account_Team__c acctem :listofrecords)
    {
        system.debug('Entered the for condition'+acctem.Account__c);
        if(acctem.Name__c!=null)
        {
            acctem.Account__c = parentrecordid;
            insertlist.add(acctem);
            system.debug('Method Entry'+insertlist);
        
        }               
       
    }
        try{
        insert insertlist;
        }
        catch(Exception ex){
         //ApexPages.addmessage(new Apexpages.Message(ApexPages.Severity.ERROR, ex.getMessage()));
         ApexPages.addMessages(ex);
         return null;
        }       
        if(listofrecords!=null){
        listofrecords.clear();
        }
        TabToBeClosed = true;
        return null;

}

public GSDAccountteammembercontroller(){
displayBOMPopUp = false;
TabToBeClosed = false;

listofrecords = new list<HPE_Account_Team__c>();
    
    for(Integer i=0; i<5; i++){   
         HPE_Account_Team__c gsdaccteam = new HPE_Account_Team__c();
         gsdaccteam.Account__c=null;
         List<PermissionSetAssignment> UserHasDCDMPerission = new List<PermissionSetAssignment>([SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'GSDAccountDCDMRole']);
         if(UserHasDCDMPerission.size() > 0)
          gsdaccteam.recordtypeid = Schema.SObjectType.HPE_Account_Team__c.getRecordTypeInfosByName().get('DCDM').getRecordTypeId();
        
         gsdaccteam.Name__c=null;
         gsdaccteam.Role_Scope_Description__c='';
         gsdaccteam.Role__c='';
                 
         listofrecords.add(gsdaccteam);
    
         }

     


public void TestActFun(){
    
displayBOMPopUp = true;
}

public void TestPopUp(){

displayBOMPopUp = true;
}

public void closeBOMPopUp() {
    
    displayBOMPopUp = false;

}  
}
Harish RamachandruniHarish Ramachandruni
Hi,

First change this code in your class dont hot code any class it wont work in test class bellow line
 
    Id parentrecordid = ApexPages.currentPage().getParameters().get('Id');
   // Id parentrecordid = '001G000001IgfGZ';
@isTest
Public  class GSDAccountteammembercontroller _test{
    static testMethod void myUnitTest() 
    {


// create 3 records intest class for  HPE_Account_Team__c

for(Integer i=0 ; i<3 ; i++){

HPE_Account_Team__c helpaccount = new HPE_Account_Team__c();


//add required field 

insert helpaccount ;



}


//Create  1 record  belongs to     Id parentrecordid = '001G000001IgfGZ';  object  take variable as rao 

// objectname rao  = new objectname (); add fields insert 

apexpages.currentpage().getparameters().put('id' , rao.id);


GSDAccountteammembercontroller  harish = new GSDAccountteammembercontroller ();

Harish.TestActFun();

Harish. TestPopUp ();

Harish. closeBOMPopUp ();

Harish. SaveRecords() ;


}
}



 
Harish RamachandruniHarish Ramachandruni
Hi,

Ask me any isuue above code .



Regards.
Harish.R.
Manjunath reddy 25Manjunath reddy 25
I have written the test class as below, but I am getting error message,
Error: Compile Error: Constructor not defined: [GSDAccountteammembercontroller].<Constructor>() at line 23 column 64, If I comment that line code is getting saved, but code will not be covered.
@isTest
public class GSDAccountteammembercontrollerTest{
    private static testMethod void SaveRecordTest(){
        account acc = new account();
        acc.name='test';
        insert acc;
        
        contact con = new contact();
        con.email = 'test@ayhoo.com';
        con.Phone__c = '5423515415';
        con.LastName ='last Name';  
        
        insert con;
        
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
        hpeAccountTeam.Account__c = acc.id;
        hpeAccountTeam.Name__c = con.id;
        hpeAccountTeam.Role__c = 'Other';
        hpeAccountTeam.Role_Scope__c = 'Global';
        hpeAccountTeam.Role_Scope_Description__c = 'testing';
        insert hpeAccountTeam;
        
        GSDAccountteammembercontroller  teamMemberController = new GSDAccountteammembercontroller();
        teamMemberController.SaveRecords();                 
    }
}
Manjunath reddy 25Manjunath reddy 25
I just want to let you know that in the main class we are not using the line,  ApexPages.currentPage().getParameters().get('Id');
Harish RamachandruniHarish Ramachandruni
Hi ,


you have to use because of no data will access  from your org data base so if you are giving id it wilol not available in test class plot form .  Add bellow code to your test class .
 
@isTest
public class GSDAccountteammembercontrollerTest{
 
 
    private static testMethod void SaveRecordTest(){
 
        account acc = new account();
        acc.name='test';
        insert acc;
       
        contact con = new contact();
        con.email = 'test@ayhoo.com';
        con.Phone__c = '5423515415';
        con.LastName ='last Name';  
       
        insert con;
       
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
        hpeAccountTeam.Account__c = acc.id;
        hpeAccountTeam.Name__c = con.id;
        hpeAccountTeam.Role__c = 'Other';
        hpeAccountTeam.Role_Scope__c = 'Global';
        hpeAccountTeam.Role_Scope_Description__c = 'testing';
        insert hpeAccountTeam;
 
 
 Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
       
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,
                          TimeZoneSidKey='America/Los_Angeles',     UserName='testpermissionsetuser@testorg.com');
        insert u;
       
        // Query your permission set name from Organization that your want to test.
        PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'AccountRating'];
       
 
   apexpages.currentpage().getparameters().put('id' , acc.id);
 
        // Assign the above inserted user for the above Permission Set.
        PermissionSetAssignment psa = new PermissionSetAssignment();
        psa.AssigneeId = u.Id;
        psa.PermissionSetId = ps.Id;
        insert psa;
       
        // Run your code with inserted user.
        System.runAs(u)
        {
  
       
        GSDAccountteammembercontroller  teamMemberController = new                  GSDAccountteammembercontroller();
        teamMemberController.SaveRecords(); 
               
    }
 
}
 
 
}



Regards ,
Harish.R.
Manjunath reddy 25Manjunath reddy 25
I have tried your code , but still I am getting the error message, 
Error: Compile Error: Constructor not defined: [GSDAccountteammembercontroller].<Constructor>() at line 38 column 68
Manjunath reddy 25Manjunath reddy 25
@isTest
public class GSDAccountteammembercontrollerTest{
    private static testMethod void SaveRecordTest(){
        account acc = new account();
        acc.name='test';
        insert acc;
        
        contact con = new contact();
        con.email = 'test@ayhoo.com';
        con.Phone__c = '5423515415';
        con.LastName ='last Name';  
        
        insert con;
        
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
        hpeAccountTeam.Account__c = acc.id;
        hpeAccountTeam.Name__c = con.id;
        hpeAccountTeam.Role__c = 'Other';
        hpeAccountTeam.Role_Scope__c = 'Global';
        hpeAccountTeam.Role_Scope_Description__c = 'testing';
        insert hpeAccountTeam;
        
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com',EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
        LocaleSidKey='en_US', ProfileId = p.Id,TimeZoneSidKey='America/Los_Angeles',UserName='testpermissionsetuser@testorg.com');
        
        insert u;
        
        PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'AccountRating'];

        apexpages.currentpage().getparameters().put('id' , acc.id);

        PermissionSetAssignment psa = new PermissionSetAssignment();
        psa.AssigneeId = u.Id;
        psa.PermissionSetId = ps.Id;
        insert psa;
        System.runAs(u){
            GSDAccountteammembercontroller  teamMemberController = new GSDAccountteammembercontroller();
            teamMemberController.SaveRecords();   
        }              
    }
}
Manjunath reddy 25Manjunath reddy 25
GSDAccountteammembercontroller  teamMemberController = new GSDAccountteammembercontroller();
 
Manjunath reddy 25Manjunath reddy 25
yes
Manjunath reddy 25Manjunath reddy 25
I did'nt get your question.
Harish RamachandruniHarish Ramachandruni
Hi,

what is methode is working in constracter .  

Email me : harish.rao.salesforce@gmail.com


Regards ,
Harish.R.
Harish RamachandruniHarish Ramachandruni
Hi ,


It's working properly in my org test it in your org.  i am created only 2 fields and one object but it will work in your org check and let me know any issue .

User-added image

 
public  class GSDAccountteammembercontroller {

public list<HPE_Account_Team__c> listofrecords{get;set;}
public Boolean displayBOMPopUp {get;set;}
public Boolean TabToBeClosed {get;set;}
    
public PageReference SaveRecords() 
{
system.debug('Method Entry');
    Id parentrecordid = ApexPages.currentPage().getParameters().get('Id');
   // Id parentrecordid = '001G000001IgfGZ';
    list<HPE_Account_Team__c> insertlist = new list<HPE_Account_Team__c>();  
    system.debug('After the Method Entry');
    for(HPE_Account_Team__c acctem :listofrecords)
    {
        system.debug('Entered the for condition'+acctem.Account__c);
        if(acctem.Name !=null)
        {
            acctem.Account__c = parentrecordid;
            insertlist.add(acctem);
            system.debug('Method Entry'+insertlist);
        
        }               
       
    }
        try{
        insert insertlist;
            
        if(listofrecords!=null){
        listofrecords.clear();
        }
            
            
        }
        catch(Exception ex){
         //ApexPages.addmessage(new Apexpages.Message(ApexPages.Severity.ERROR, ex.getMessage()));
         ApexPages.addMessages(ex);
         return null;
        }       
      
        TabToBeClosed = true;
        return null;

}

public GSDAccountteammembercontroller(){
displayBOMPopUp = false;
TabToBeClosed = false;

listofrecords = new list<HPE_Account_Team__c>();
    
    for(Integer i=0; i<5; i++){   
         HPE_Account_Team__c gsdaccteam = new HPE_Account_Team__c();
         gsdaccteam.Account__c=null;
         List<PermissionSetAssignment> UserHasDCDMPerission = new List<PermissionSetAssignment>([SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'GSDAccountDCDMRole']);
         if(UserHasDCDMPerission.size() > 0)
          gsdaccteam.recordtypeid = Schema.SObjectType.HPE_Account_Team__c.getRecordTypeInfosByName().get('DCDM').getRecordTypeId();
        
         gsdaccteam.Name=null;
       //  gsdaccteam.Role_Scope_Description__c='';
       //  gsdaccteam.Role__c='';
                 
         listofrecords.add(gsdaccteam);
    
         }

     
} 

public void TestActFun(){
    
displayBOMPopUp = true;
}

public void TestPopUp(){

displayBOMPopUp = true;
}

public void closeBOMPopUp() {
    
    displayBOMPopUp = false;

}  
}





 
@isTest
public class GSDAccountteammembercontrollerTest{
 
 
    private static testMethod void SaveRecordTest(){
 
        account acc = new account();
        acc.name='test';
        insert acc;
       
        contact con = new contact();
        con.email = 'test@ayhoo.com';
        //con.Phone__c = '5423515415';
        con.LastName ='last Name';  
       
        insert con;
       
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
        hpeAccountTeam.Account__c = acc.id;
        hpeAccountTeam.Name = con.id;
     //   hpeAccountTeam.Role__c = 'Other';
      //  hpeAccountTeam.Role_Scope__c = 'Global';
    //    hpeAccountTeam.Role_Scope_Description__c = 'testing';
        insert hpeAccountTeam;
 
 
 Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
       
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,
                          TimeZoneSidKey='America/Los_Angeles',     UserName='testpermissionsetuser@testorg.com');
        insert u;
       
        // Query your permission set name from Organization that your want to test.
       // PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GSDAccountDCDMRole'];
       
 
   apexpages.currentpage().getparameters().put('id' , acc.id);
 
        // Assign the above inserted user for the above Permission Set.
     /*   PermissionSetAssignment psa = new PermissionSetAssignment();
        psa.AssigneeId = u.Id;
        psa.PermissionSetId = ps.Id;
        insert psa;*/
       
        // Run your code with inserted user.
        System.runAs(u)
        {
  
       
        GSDAccountteammembercontroller  teamMemberController = new     GSDAccountteammembercontroller();
        teamMemberController.SaveRecords(); 
                teamMemberController.TestActFun(); 

        teamMemberController.TestPopUp(); 

        teamMemberController.closeBOMPopUp(); 

        
       // TestActFun()
               
    }
 
}
 
 
}



Regards ,
Harish.R.
harish.rao.salesforce@gmail.com
Harish RamachandruniHarish Ramachandruni
Hi, 

Did u get code coverage .


Regards ,
Harish.R
Manjunath reddy 25Manjunath reddy 25
Are you able to save test class in your org.
Manjunath reddy 25Manjunath reddy 25
Now I have changed the main class as below
public  class GSDAccountteammembercontroller {


public list<HPE_Account_Team__c> listofrecords{get;set;}
public Boolean displayBOMPopUp {get;set;}
public Boolean TabToBeClosed {get;set;}
    
public PageReference SaveRecords() 
{
system.debug('Method Entry');
    string parentrecordid = ApexPages.currentPage().getParameters().get('Account__c');
    //Id parentrecordid = '001G000001IgfGZ';
    list<HPE_Account_Team__c> insertlist = new list<HPE_Account_Team__c>();  
    system.debug('After the Method Entry');
    for(HPE_Account_Team__c acctem :listofrecords)
    {
        system.debug('Entered the for condition'+acctem.Account__c);
        if(acctem.Name__c!=null)
        {
          if(parentrecordid != null && parentrecordid != '')
          acctem.Account__c = parentrecordid ;
          insertlist.add(acctem);
        
        }              
       
    }
        try{
        insert insertlist;
        }
        catch(Exception ex){
         //ApexPages.addmessage(new Apexpages.Message(ApexPages.Severity.ERROR, ex.getMessage()));
         ApexPages.addMessages(ex);
         return null;
        }       
        if(listofrecords!=null){
        listofrecords.clear();
        }
        TabToBeClosed = true;
        return null;

}

public GSDAccountteammembercontroller(ApexPages.StandardController controller){
 HPE_Account_Team__c HPEAccountTeam=(HPE_Account_Team__c)controller.getrecord();
 system.debug('HPEAccountTeam'+HPEAccountTeam);
displayBOMPopUp = false;
TabToBeClosed = false;

listofrecords = new list<HPE_Account_Team__c>();
    
    for(Integer i=0; i<5; i++){   
         HPE_Account_Team__c gsdaccteam = new HPE_Account_Team__c();
         gsdaccteam.Account__c=HPEAccountTeam.Account__c;        
         gsdaccteam.Name__c=null;
         gsdaccteam.Role_Scope_Description__c='';
         gsdaccteam.Role__c='';
                 
         listofrecords.add(gsdaccteam);
    
         }

     
} 

public void TestActFun(){
    
displayBOMPopUp = true;
}

public void TestPopUp(){

displayBOMPopUp = true;
}

public void closeBOMPopUp() {
    
    displayBOMPopUp = false;

}  
}
Harish RamachandruniHarish Ramachandruni
Hi,

in line number 11 

change 

    string parentrecordid = ApexPages.currentPage().getParameters().get('id');

please exectie my total class and test class once .

Downlode ypur code and copy past my code in your org . it will work .


Regards ,
Harish.

 
Manjunath reddy 25Manjunath reddy 25
In your code you are not using standardcontroller(ApexPages.StandardController controller).
Harish RamachandruniHarish Ramachandruni
Hi,

Update this code .

class 
 
public  class GSDAccountteammembercontroller {

public list<HPE_Account_Team__c> listofrecords{get;set;}
public Boolean displayBOMPopUp {get;set;}
public Boolean TabToBeClosed {get;set;}
    
public PageReference SaveRecords() 
{
system.debug('Method Entry');
    Id parentrecordid = ApexPages.currentPage().getParameters().get('Id');
   // Id parentrecordid = '001G000001IgfGZ';
    list<HPE_Account_Team__c> insertlist = new list<HPE_Account_Team__c>();  
    system.debug('After the Method Entry');
    for(HPE_Account_Team__c acctem :listofrecords)
    {
        system.debug('Entered the for condition'+acctem.Account__c);
        if(acctem.Name !=null)
        {
            acctem.Account__c = parentrecordid;
            insertlist.add(acctem);
            system.debug('Method Entry'+insertlist);
        
        }               
       
    }
        try{
        insert insertlist;
            
        if(listofrecords!=null){
        listofrecords.clear();
        }
            
            
        }
        catch(Exception ex){
         //ApexPages.addmessage(new Apexpages.Message(ApexPages.Severity.ERROR, ex.getMessage()));
         ApexPages.addMessages(ex);
         return null;
        }       
      
        TabToBeClosed = true;
        return null;

}

public GSDAccountteammembercontroller(ApexPages.StandardController controller){
displayBOMPopUp = false;
TabToBeClosed = false;

listofrecords = new list<HPE_Account_Team__c>();
    
    for(Integer i=0; i<5; i++){   
         HPE_Account_Team__c gsdaccteam = new HPE_Account_Team__c();
         gsdaccteam.Account__c=null;
         List<PermissionSetAssignment> UserHasDCDMPerission = new List<PermissionSetAssignment>([SELECT PermissionSetId FROM PermissionSetAssignment WHERE AssigneeId= :UserInfo.getUserId() AND PermissionSet.Name = 'GSDAccountDCDMRole']);
         if(UserHasDCDMPerission.size() > 0)
          gsdaccteam.recordtypeid = Schema.SObjectType.HPE_Account_Team__c.getRecordTypeInfosByName().get('DCDM').getRecordTypeId();
        
         gsdaccteam.Name=null;
       //  gsdaccteam.Role_Scope_Description__c='';
       //  gsdaccteam.Role__c='';
                 
         listofrecords.add(gsdaccteam);
    
         }

     
} 

public void TestActFun(){
    
displayBOMPopUp = true;
}

public void TestPopUp(){

displayBOMPopUp = true;
}

public void closeBOMPopUp() {
    
    displayBOMPopUp = false;

}  
}


Test class 

 
@isTest
public class GSDAccountteammembercontrollerTest{
 
 
    private static testMethod void SaveRecordTest(){
 
        account acc = new account();
        acc.name='test';
        insert acc;
       
        contact con = new contact();
        con.email = 'test@ayhoo.com';
        //con.Phone__c = '5423515415';
        con.LastName ='last Name';  
       
        insert con;
       
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
        hpeAccountTeam.Account__c = acc.id;
        hpeAccountTeam.Name = con.id;
     //   hpeAccountTeam.Role__c = 'Other';
      //  hpeAccountTeam.Role_Scope__c = 'Global';
    //    hpeAccountTeam.Role_Scope_Description__c = 'testing';
        insert hpeAccountTeam;
 
 
 Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
       
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
                          EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
                          LocaleSidKey='en_US', ProfileId = p.Id,
                          TimeZoneSidKey='America/Los_Angeles',     UserName='testpermissionsetuser@testorg.com');
        insert u;
       
        // Query your permission set name from Organization that your want to test.
       // PermissionSet ps = [SELECT Id FROM PermissionSet WHERE Name = 'GSDAccountDCDMRole'];
       
 
   apexpages.currentpage().getparameters().put('id' , acc.id);
 
        // Assign the above inserted user for the above Permission Set.
     /*   PermissionSetAssignment psa = new PermissionSetAssignment();
        psa.AssigneeId = u.Id;
        psa.PermissionSetId = ps.Id;
        insert psa;*/
       
        // Run your code with inserted user.
        System.runAs(u)
        {
      
      
         ApexPages.StandardController con1 = new ApexPages.StandardController(hpeAccountTeam);

       
        GSDAccountteammembercontroller  teamMemberController = new     GSDAccountteammembercontroller(con1 );
        teamMemberController.SaveRecords(); 
                teamMemberController.TestActFun(); 

        teamMemberController.TestPopUp(); 

        teamMemberController.closeBOMPopUp(); 

        
       // TestActFun()
               
    }
 
}
 
 
}

Add this add aded all things in this code 

 
Harish RamachandruniHarish Ramachandruni
Hi ,


Any issue ask me immediatly .


Regards ,
Harish.R
Manjunath reddy 25Manjunath reddy 25
Test class is failing 
error is 
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, User Role Type is Required: [EmailPreferences]
Class.GSDAccountteammembercontrollerTest.SaveRecordTest: line 27, column 1

line 27 is
 insert u;
Manjunath reddy 25Manjunath reddy 25
Hi Harish,

Now test class is passing my code is as below, code coverage is 84%, but I need to increase another 2 percent.

if(parentrecordid != null && parentrecordid != '')
          acctem.Account__c = parentrecordid ;
          insertlist.add(acctem);

the above lines are not getting covered.
@isTest
public class GSDAccountteammembercontrollerTest{
    private static testMethod void SaveRecordTest(){
        account acc = new account();
        acc.name='test';
        insert acc;
        
        contact con = new contact();
        con.email = 'test@ayhoo.com';
        con.Phone__c = '5423515415';
        con.LastName ='last Name';  
        insert con;
        
        HPE_Account_Team__c hpeAccountTeam = new HPE_Account_Team__c();
        hpeAccountTeam.Account__c = acc.id;
        hpeAccountTeam.Name__c = con.id;
        hpeAccountTeam.Role__c = 'Other';
        hpeAccountTeam.Role_Scope__c = 'Global';
        hpeAccountTeam.Role_Scope_Description__c = 'testing';
        insert hpeAccountTeam;
        
        Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];

        apexpages.currentpage().getparameters().put('id',acc.id);
  
        user u = [select id from user where id=:userInfo.getUserId()];
        
        System.runAs(u){
            ApexPages.StandardController con1 = new ApexPages.StandardController(hpeAccountTeam);
            GSDAccountteammembercontroller  teamMemberController = new GSDAccountteammembercontroller(con1);
            teamMemberController.SaveRecords();   
            teamMemberController.TestActFun();
            teamMemberController.TestPopUp();
            teamMemberController.closeBOMPopUp();     

        }              
    }
}

 
Harish RamachandruniHarish Ramachandruni
hi,
Add 


Modify this lines upadte below code  after 
   //     insert hpeAccountTeam; line 

 
UserRole ur = [Select PortalType, PortalAccountId From UserRole where PortalType =:'CustomerPortal' limit 1];

Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];        
        User u = new User(Alias = 'standt', Email='standarduser@testorg.com',
                        EmailEncodingKey='UTF-8', LastName='Testing',LanguageLocaleKey='en_US',
                         LocaleSidKey='en_US', ProfileId = p.Id,
                         TimeZoneSidKey='America/Los_Angeles',   UserName='testpermissionsetuser@testorg.com');
       insert u;



Regards ;
Harish.R.
        
 
Manjunath reddy 25Manjunath reddy 25
Hi Harish,

My test class is working fine now, I just need to cover the lines below from the main class.

if(acctem.Name__c!=null)
        {
          if(parentrecordid != null && parentrecordid != '')
          acctem.Account__c = parentrecordid ;
          insertlist.add(acctem);
        
        } 
 
Harish RamachandruniHarish Ramachandruni
Hi,

what is the code coverage now .


Regards ,
Harish.R

 
Manjunath reddy 25Manjunath reddy 25
 code coverage now is 84%