You need to sign in to do that
Don't have an account?
Maok kinesle
Hi I have tried code coverage for below test class But it covers only30% ,anyone please help me to make 80%
Original code:
public class MessageAlert {
@auraenabled
public static Boolean getmessages(String recordId){
Boolean checkExpDate = False;
List<LVSCR_c> contactList = new List<LVSCR_c>();
Set<String> newSet = new Set<String>();
// Set<String> existingSet = new Set<String>();
for ( LVSCR__c lvs : contactList ) {
system.debug(lvs);
if ( lvs.Contact__c != null ) {
newSet.add(lvs.Contact__c);
}
}
system.debug('newset--->>'+newSet);
List <LVSCR_c> soql = new List<LVSCR_c>();
soql = [SELECT Id,Contact_c FROM LVSCRc WHERE Id =: recordId AND Contact_c IN: newSet];
system.debug('soql--->'+soql);
if(soql.size()>0){
//checkExpDate = True;
}
else{
checkExpDate = False;
}
return checkExpDate;
}
}
I hav tried but Its not covering the whole code.
apex test class:
@isTest
private class MessageAlertTest{
@isTest
static boolean getmessages(){
List<LVSCR_c> conlist = new List<LVSCR_c>();
Boolean checkExpDate = False;
Lvscr_c lvscrcObj = new Lvscr_c ();
lvscrcObj.Id='0012600001Ck4AEAA';
lvscrcObj.Contact__c = '0012600001Ck4AEAA';
lvscrcObj.Delivery_Type__c ='Original';
lvscrcObj.LAFS__c = '122255';
lvscrcObj.Tamm_Authorisation__c ='Yes';
conlist.add(lvscrcObj);
update conlist;
return checkExpDate;
}
@isTest static void testMethod1() {
// code_block
}
@isTest static void testMethod2() {
// code_block
}
}
public class MessageAlert {
@auraenabled
public static Boolean getmessages(String recordId){
Boolean checkExpDate = False;
List<LVSCR_c> contactList = new List<LVSCR_c>();
Set<String> newSet = new Set<String>();
// Set<String> existingSet = new Set<String>();
for ( LVSCR__c lvs : contactList ) {
system.debug(lvs);
if ( lvs.Contact__c != null ) {
newSet.add(lvs.Contact__c);
}
}
system.debug('newset--->>'+newSet);
List <LVSCR_c> soql = new List<LVSCR_c>();
soql = [SELECT Id,Contact_c FROM LVSCRc WHERE Id =: recordId AND Contact_c IN: newSet];
system.debug('soql--->'+soql);
if(soql.size()>0){
//checkExpDate = True;
}
else{
checkExpDate = False;
}
return checkExpDate;
}
}
I hav tried but Its not covering the whole code.
apex test class:
@isTest
private class MessageAlertTest{
@isTest
static boolean getmessages(){
List<LVSCR_c> conlist = new List<LVSCR_c>();
Boolean checkExpDate = False;
Lvscr_c lvscrcObj = new Lvscr_c ();
lvscrcObj.Id='0012600001Ck4AEAA';
lvscrcObj.Contact__c = '0012600001Ck4AEAA';
lvscrcObj.Delivery_Type__c ='Original';
lvscrcObj.LAFS__c = '122255';
lvscrcObj.Tamm_Authorisation__c ='Yes';
conlist.add(lvscrcObj);
update conlist;
return checkExpDate;
}
@isTest static void testMethod1() {
// code_block
}
@isTest static void testMethod2() {
// code_block
}
}
Hi,
You can take references from this code.
Please mark it as the best Answer if your queries are solved.
Thank You