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
SalesforcedevSalesforcedev 

Test apex classe

public class Campaign{
    @AuraEnabled
    public String campaignId{get;set;}
    @AuraEnabled
    public String email_dispatch_date{get;set;}
    @AuraEnabled
    public String campaignLabel{get;set;}
someone can help me about the method for the unit test for this apex classe?
Manohar kumarManohar kumar

Hi Yang,

pls try something like this


 

@isTest
public class TestCampaign {

 @isTest
    public static void runTest(){
    Campaign c1 = new Campaign();
        c1.campaignId = 'test13';
        c1.email_dispatch_date = 'test22';
        c1.campaignlabel = 'test1';
    }
}


pls let me know if this works . 

Manohar

SalesforcedevSalesforcedev
Hello Manohar,
There's also this as type and variable : public Boolean flag_email_clicked{get;set;}
                                               @AuraEnabled
if i write it like this,is it correct?
c1.flag_email_clicked =' ';

 
Manohar kumarManohar kumar

Hi Yang,

I think putting '', will give error. '' would be considerd as string. You better put true or false, since its a boolean. 

Manohar

SalesforcedevSalesforcedev
Hi Manohar,
When i run the test Classe,but i got this like error message.User-added image,like i am beginner with dev,so i need your help.
Thank you very much
Manohar kumarManohar kumar

Hi Yang, 

Happy to help.  Its saying classId is null, there there any variable classId in your clas? You can also use Apex Test execution frrom the org.
It will tell you the line number. Can you can from that and put a snap shot of you class with error.

Thanks,
Manohar

 

SalesforcedevSalesforcedev
Hi Manohar,
It s the apex class from the first message with error message screen shot

Yang
Manohar kumarManohar kumar

Hi Yang,

Sorry for the late reply. 
Have you figured out the error.

Thanks,
Manohar