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
Swetha B 7Swetha B 7 

Trigger Code Coverage help

Please help code coverage for my trigger

Apex Trigger

trigger AccountAddressTrigger on Apartment_Property__c (before insert, before update) {

 Set<String> reviewList = new Set<String>();  

 for(Apartment_Property__c a : trigger.new) {
        if( a.multi__c!= null){
            List<String> review = a.multi__c.split(';');
            reviewList.addAll(review);
        }        
           string reviewLogs = '';
           if(reviewList.size()>0) {
             
             for(string r: reviewList) {
                 if(r == 'A') {
                     reviewLogs += Label.Test+'\n';
                 }                
                 if(r == 'B') {
                    reviewLogs += Label.Test1+'\n';
                 }
               
                 if(r == 'c') {
                    reviewLogs += Label.Test3+'\n';
                 }
            }

        }
               a.Longtext__c = reviewLogs;
    }
}
Test Class: Written below test class but am not able to code coverage, Please help  

@isTest
public class AccountAddressTrigger {
    public static testmethod void utilitytestACTIVITY() {

    list<Apartment_Property__c> Acc = new list<Apartment_Property__c>();
        Apartment_Property__c obj = new Apartment_Property__c();
        obj.multi__c ='abe';
        obj.Longtext__c  ='xyz';
        Acc.add(obj);
        insert Acc;
}
}

Thnaks for the help!
Best Answer chosen by Swetha B 7
Raj VakatiRaj Vakati
try this
@isTest
public class AccountAddressTrigger {
    public static testmethod void utilitytestACTIVITY() {

    list<Apartment_Property__c> Acc = new list<Apartment_Property__c>();
        Apartment_Property__c obj = new Apartment_Property__c();
        obj.multi__c ='A;B;C';
        obj.Longtext__c  ='xyz';
        Acc.add(obj);
        insert Acc;
}
}

 

All Answers

Raj VakatiRaj Vakati
try this
@isTest
public class AccountAddressTrigger {
    public static testmethod void utilitytestACTIVITY() {

    list<Apartment_Property__c> Acc = new list<Apartment_Property__c>();
        Apartment_Property__c obj = new Apartment_Property__c();
        obj.multi__c ='A;B;C';
        obj.Longtext__c  ='xyz';
        Acc.add(obj);
        insert Acc;
}
}

 
This was selected as the best answer
Swetha B 7Swetha B 7
Thanks for the quick response!

Sorry i missed simple logic to add ;(simicolon) :(