function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ItsMeSolItsMeSol 

Test class

What would be the text class of this

 

  public static void ProdMeetNull (Item__c[] ProdMeetBlank ){
        for (Item__c I :ProdMeetBlank){
            if (I.product_meeting__c != null && I.Request_Rejected__c== True && I.Request_Approved__c == False) {
             I.Product_Meeting__c = null;  
            }
        }    
    }
sivaextsivaext

Hi 

 

create list of items first in test class and call this method parameters

 

 public class testclass{

 

      List <Item> ltList = new List<Item>();

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

 

          item i1 = new item(name = 'iyem'+i, required field for inserting);

          ltList.add(i1);

}

insert liList;

 className.prodMettNull(ltList);

}

ItsMeSolItsMeSol

this is my tets class but still its zero%. I am new in salesforce programming.

 

Item__c Itm = New Item__c();
Itm.product_meeting__c='a0bW0000000Dt77';
Itm.Request_Rejected__c = True;
Itm.Request_Approved__c = False;
Itm.Project_Name__c = 'a0RW0000000225n';
Itm.Status__c= 'Draft';
Itm.Item__c = 'Simulation';
Itm.Final_SKU__c = 'TEST Only';
Itm.Decision__c= 'Approved';
Itm.Plant__c = 'a0XW0000000I30V';

Test.startTest();
try {
Database.insert(Itm);
} catch(DMLException e)
{
}

System.assertEquals(false, Itm.product_meeting__c == null);
Test.stopTest();
//Item__c ItemTest = [SELECT id,product_meeting__c FROM Item__c WHERE id = :Itm.product_meeting__c ALL ROWS];
//System.assertNotEquals(ItemTest.product_meeting__c, null);
// System.assert(e.getMessage().contains('Blank'));




}

ItsMeSolItsMeSol
Thanks for the reply, below is my test class: Item__c Itm = New Item__c(); Itm.product_meeting__c='a0bW0000000Dt77'; Itm.Request_Rejected__c = True; Itm.Request_Approved__c = False; Itm.Project_Name__c = 'a0RW0000000225n'; Itm.Status__c= 'Draft'; Itm.Item__c = 'Simulation'; Itm.Final_SKU__c = 'TEST Only'; Itm.Decision__c= 'Approved'; Itm.Plant__c = 'a0XW0000000I30V'; Test.startTest(); try { Database.insert(Itm); } catch(DMLException e) { } System.assertEquals(false, Itm.product_meeting__c == null); Test.stopTest(); //Item__c ItemTest = [SELECT id,product_meeting__c FROM Item__c WHERE id = :Itm.product_meeting__c ALL ROWS]; //System.assertNotEquals(ItemTest.product_meeting__c, null); // System.assert(e.getMessage().contains('Blank')); } ________________________________ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy. ______________________________________________________________________________________ www.accenture.com