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
satyamsatyam 

Please help to solve my Trigger Test Class Problem

Hi,

 

Below is my trigger and Test Class

 

Red Colur line i am not covering in test class means if conditon is not checking in trigger test class

Trigger:
trigger Recruitervalidation on Recruiter__C (before Update) {  
    for (Recruiter__c a : Trigger.new) {
        system.debug('a.Status__c '+a.Status__c);
        system.debug('a.jobname__C '+a.jobname);
        
        if ((a.Status__c == 'waiting')&&(a.jobname__c==null)) {
                
            a.addError('Please fill the "Jobname" for the Job');
        }
       else if ((a.Status__c == 'Pending')&&(a.Jobdesc==null)) {
                
            a.addError(‘Some Error Message');
        }                                                         
    }
}

Test Class:

@istest

private class Recruitervalidation_test{

public static testmethod void Recruitervalidation_test()

{

Recruiter__c rc = new Recruiter_c();

rc.status__c='waiting';

rc.jobname__c='';

rc.joblocation__C='INDIA';

rc.jobtype__C='Technical';

insert rc;

rc.status__C='pending';

rc.jobdesc__C='';

rc.joblocation__C='INDIA';


update rc;

}}

 

Thanks

SFRajSFRaj

Hi,

 

private class Recruitervalidation_test{

public static testmethod void Recruitervalidation_test()

{

Recruiter__c rc = new Recruiter_c();

rc.status__c='waiting';

rc.jobname__c=NULL or delete this line;

rc.joblocation__C='INDIA';

rc.jobtype__C='Technical';

insert rc;

rc.status__C='pending';

rc.jobdesc__C='';

rc.joblocation__C='INDIA';


update rc;

}}