• Travis Dvorak 10
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I have a flow that generates a random string to update a field.  My problem I'm having is that the test class method isn't show up when I run the test, so I have 0% coverage and the test method isn't showing up in the drop down for "Code Coverage: None"

Code:
 
public with sharing class GenerateToken {
    @InvocableMethod
    
    public static void GenerateEmailToken(list<Account> accList){
        integer len = 16;
		blob blobkey = crypto.generateAesKey(128);
   		String key = EncodingUtil.convertToHex(blobKey);
		String token = key.substring(0,len);
        System.debug('Token is ' + token);
        
        accList[0].put('CX_Registration_Token__pc', token);
        update accList;
     }
}


Test Class:

@isTest
public class GenerateTokenTest {
    
    @isTest    
    Public Static void GenerateEmailToken(){
                
        list<Account> accList = new List<Account>();
        
        integer len = 16;
		blob blobkey = crypto.generateAesKey(128);
   		String key = EncodingUtil.convertToHex(blobKey);
		String token = key.substring(0,len);
        
    	Account pa = new Account(
                                FirstName='TestAccount2',
                                LastName='TestAccount2', 
                                RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Person Account').getRecordTypeId()
                               
                            );

    insert pa;
    
    accList.add(pa);
        Test.startTest();
        
        pa.CX_Registration_Token__pc = 'token';        
        update pa;
        
        System.assertEquals(token,pa.CX_Registration_Token__pc);
        Test.stopTest();
    }
   
    
}

I'm pretty much on the beginning stages of my journey of development, so it's very possible this makes zero sense how it's written.  Apologies if that's the case.