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
vicky kr 3vicky kr 3 

Need Help In Writing Test Class,,Apex Code Is Working Perfectly

public class eventCreation {
//eventCreation.demoEvent();
    public static void demoEvent(){
Event newEvent = new Event();
newEvent.OwnerId = '0055i000003MTGlAAO';
newEvent.Subject ='Testing Demo event';
//newEvent.WhatId = recordId;
newEvent.ActivityDate = System.today();
newEvent.IsRecurrence = true;
newEvent.RecurrenceStartDateTime = System.today();
newEvent.RecurrenceEndDateOnly = System.today()+30;
newEvent.RecurrenceType = 'RecursDaily';
newEvent.RecurrenceInterval = 1;
newEvent.IsAllDayEvent =true;
newEvent.DurationInMinutes =1440;

insert newEvent;
    }
}
Best Answer chosen by vicky kr 3
CharuDuttCharuDutt
Hii Vicky
Try below Code 100% Coverage
@isTest
public class eventCreationTest {
	@isTest
    public static void unitTest(){
        eventCreation.demoEvent();
    }
}
Please Mark It As Best Asnwer If It Helps
Thank You!

All Answers

CharuDuttCharuDutt
Hii Vicky
Try below Code 100% Coverage
@isTest
public class eventCreationTest {
	@isTest
    public static void unitTest(){
        eventCreation.demoEvent();
    }
}
Please Mark It As Best Asnwer If It Helps
Thank You!
This was selected as the best answer
AnkaiahAnkaiah (Salesforce Developers) 
Hi Vicky,

try with below code.
@isTest
public class eventCreationTest {
	
    static testmethod void eventCreationmethod(){
        eventCreation.demoEvent();
    }
}

Thanks!!
vicky kr 3vicky kr 3
Thanks Both of you Its completely working fine