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
mukesh guptamukesh gupta 

Code Not Covered by Test Class

Hi Expert,

I am using a test class for coverage 75% code, but few things are not covered. Can any one suggest what is going wrong.

this my test Class: --
public class TestProfessorSelectCourse {
    @isTest static void ProfessorCourse(){
        Professor__c prof = new Professor__c(Name ='JP',Email__c='');
        insert prof;
        Class__c cls = new Class__c(name='12G', Class_Teacher__c =;
        insert cls;
        Course__c cors = new Course__c(,Class__c, name='Ruby', Start_Date__c= , End_date__c= Date.newInstance(2017,03,20));
       	//Professor__c prof = new Professor__c(Name ='JP');
        //cors.Professor__c = prof.Name;
        insert cors;

and below is my main class

User-added image

Best Answer chosen by mukesh gupta
Shashikant SharmaShashikant Sharma
Hi Mukesh,

You need to

1. Change your trigger to after insert and make below changes.
2. remove one line
3. loop over

User-added image