Salesforce creazione dati per classe di test

Ecco un esempio di metodo per la creazione di dati in una classe di test

@TestSetup
    static void setup(){

        Date today = Date.today();
        Date tomorrow = today.addDays(1);

        // creare il Service Appointment
        ServiceAppointment serviceAppointment = new ServiceAppointment();
        serviceAppointment.EarliestStartTime = date.parse(String.valueOf(today.day() + '/' + today.month() + '/' + today.year()));
        serviceAppointment.DueDate = date.parse(String.valueOf(tomorrow.day() + '/' + tomorrow.month() + '/' + tomorrow.year()));
        serviceAppointment.ParentRecordId = workOrder.Id;
        serviceAppointment.Status = 'None';        
        serviceAppointment.SchedStartTime = date.parse(String.valueOf(today.day() + '/' + today.month() + '/' + today.year()));
        serviceAppointment.SchedEndTime = date.parse(String.valueOf(today.day() + '/' + today.month() + '/' + tomorrow.year()));
        //ServiceAppointment.ServiceTerritoryId,
        //ServiceAppointment.Status          
        insert serviceAppointment;
        
        // creare la service crew
        ServiceCrew serviceCrew = new ServiceCrew();
        serviceCrew.Name = 'Service Crew Test';
        serviceCrew.CrewSize = 20;
        insert serviceCrew;


        // creare l'assigned resource                
        AssignedResource assignedResource = new AssignedResource();
        assignedResource.ServiceAppointmentId = serviceAppointment.id;
        assignedResource.ServiceResourceId = serviceResource.id;
        assignedResource.EstimatedTravelTime = 11.00;
        assignedResource.ActualTravelTime = 12.00;
        assignedResource.ServiceCrewId = serviceCrew.id;
        insert assignedResource;

    }