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
arun Bikkasaniarun Bikkasani 

hi all can you help for writing test class for below trigger

hi i have two objects student__c  and Library__c both are related ojects

trigger createLibrary on student__c (after insert,after delete) {
handler class:
public class studentTriggerHandler{

    public static void onStudentInsert(List<student__c> studRecs){
        List<Library__c> lib1=new List<Library__c>(); 
        for(student__c std : studRecs){
            Library__c lib=new Library__c();
        if(lib1.size() > 0){
                insert lib1;
            }catch(Exception ex){
    public static void onStudentDelete(List<student__c> oldStudRecs){
        list<id> stdlist=new list<id>();
        for(student__c  str : oldStudRecs){
        list<Library__c > liblist=[select id from Library__c where studentname__c in :stdlist];
        delete liblist;

Hi Arun,

What is the issue you are actually having difficulty with, if you could direct us to a more specific problem then we will be in a better position to assist. Post the test class you have written so far and explain the problem and we can take a look.
Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Arun Bikkasani, I hope it will be helpful.

Please mark it as best answer if the information is informative.

Best Regards
Rahul Kumar