• Kartikeya Gaur
  • NEWBIE
  • 3 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies
Test Class methods are passing But but when i am checking the Code Coverage it is giving me 0% coverage  & there is No is Color Code to show test class below  

@isTest
public class TestcardProgramsolparticipationcheck {
 public static testMethod void testRunAs() {
        // Setup test data
        // This code runs as the system user
        Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator']; 
        User u = new User(Alias = 'sysadm', Email='systemuser@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, EmployeeNumber='12015',
            TimeZoneSidKey='America/Los_Angeles', UserName='csubodh@pscu.com');

        System.runAs(u) {
            // The following code runs as user 'u' 
            System.debug('Current User: ' + UserInfo.getUserName());
            System.debug('Current Profile: ' + UserInfo.getProfileId()); 
            
           
       }
   }
    Public static testMethod void method1()
     {
         List<Account> acc = new List<Account>();
         for(Integer i=0;i>=200;i++){
             Account a = new account(Name='XYZ'+i);
             acc.add(a);
         }
       
         List<Card_Program__c> cp =new List<Card_Program__c>();
         for(Integer i=0;i>=200;i++){
             Card_program__c cpr =new Card_Program__c(FI__c='12 Financial CU'+i,Card_Processor_Status__c='ACTIVE');
             cp.add(cpr);
         }
         test.starttest();
           Insert acc;
           Insert cp;
        
         List<Solution_Participation__c> spn= new List<Solution_Participation__c>();
         for(Integer i=0;i>=200;i++){
            Solution_Participation__c spr = new Solution_Participation__c(Card_Program__c='11800883',Active__c= true);
     }  
          List<Card_Program__c> cps =new List<Card_Program__c>();
         for(Integer i=0;i>=200;i++){
             Card_program__c cprs =new Card_Program__c(FI__c='12 Financial CU'+i,Card_Processor_Status__c='INACTIVE');
// FI__c is a lookup field from Account.

             cps.add(cprs);
         }
           Insert cps;
        
         List<Solution_Participation__c> sp= new List<Solution_Participation__c>();
         for(Integer i=0;i>=200;i++){
            Solution_Participation__c sprs = new Solution_Participation__c(Card_Program__c='11800884',Active__c= False);
         }
        test.stoptest();     
}
}

Actual Class --
Public class cardProgramsolparticipationcheck{

 Public Static Void checkFieldstatus(List<Card_Program__c> card){
    Map<id,Card_Program__c> programIds = new Map<id,Card_Program__c>();
    for(Card_Program__c cp : card){
    if(cp.card_processor_status__c != null){
        programIds.put(cp.id,cp);
      }
    }
    
    List<Solution_participation__c> updChildrecs = new List<Solution_participation__c>();
    List<Solution_participation__c> childrecs = [select id,Active__c,Card_Program__c from Solution_participation__c where Card_Program__c IN : programIds.keyset()];
    
    if(childrecs.size()>0){
      for(Solution_participation__c sp : childrecs){
        if(programIds.get(sp.Card_Program__c).card_processor_status__c == 'INACTIVE'){
           sp.Active__c = FALSE;
        }else {
           sp.Active__c = TRUE;
         }           
           updChildrecs.add(sp);
      }
      if(updChildrecs.size()>0){
          Update updChildrecs;
      }
     
    
    }



}
}
Trailhead Module 3:  Create a formula field that determines the number of days between today and the last activity date for a case's account.
Your support team has asked for improved visibility on account activity level at the time they’re helping with customer issues. Specifically, when they’re looking at a case, they’d like to see an at-a-glance view of the number of days since the case’s related account was last active. Create the formula using these requirements.The formula should be on the Case object.
The formula should be of return type Number.
The formula should be named 'Days Since Last Update' and have a resulting API Name of 'Days_Since_Last_Update__c'.
The formula should return the number of days between the account’s Last Activity Date and today.

I created the following:

I created a new custom formula field with return type number and called Days Since Last Update.
I created this formula: Account.LastActivityDate - TODAY()

I get this error message:

Challenge not yet complete... here's what's wrong: 
The 'Days_Since_Last_Update__c' formula field did not return the correct number of days between an Account’s Last Activity Date and today

Can you please assist what I did wrong?  I'm not sure if my formula is even correct with the challenge.  Please help!

Thank you.