You need to sign in to do that
Don't have an account?
Haseeb Ahmad 9
Apex class not getting code coverage
Hello all,
I have the apex class which not getting any code coverage would you able to help me fix it or what is wrong here, thank you.
Class:
test:
I have the apex class which not getting any code coverage would you able to help me fix it or what is wrong here, thank you.
Class:
public class ChangePassword { @InvocableMethod( label = 'User Password Reset' description = 'User Password Reset' ) public static List <String> getUserId (List <ID> ids){ List<String> userId = new List <String> (); List<User> userList = [SELECT Id from User WHERE IsActive = true AND CreatedDate = TODAY AND LastLoginDate = NULL AND LastPasswordChangeDate = NULL AND Id in :ids LIMIT 100]; for(User u : userList) { system.resetPassword(u.Id, true); System.debug('DONE: ' + u.Id); } return userId; } }
test:
@isTest private class ChangePasswordTest { @testSetup static void ChangePassword () { Profile p = [ SELECT id FROM Profile WHERE name = 'Standard User' ]; Test.startTest(); User u = new User (); u.firstName = 'test1'; u.lastName = 'test2'; u.ProfileId = p.Id ; u.Username = 'test@email4x.com' ; u.Email = 'test@email.com'; u.Alias = 't1'; u.EmailEncodingKey = 'ISO-8859-1'; u.LocaleSidKey = 'en_US' ; u.TimeZoneSidKey = 'America/Los_Angeles'; u.LanguageLocaleKey = 'en_US' ; Insert u ; system.resetPassword(u.Id, true); System.debug('DONE: ' + u.Id); Test.stopTest(); } }
Try Below Test Class Made Some Change Please Mark It As Best Answer If It Helps Thank You!
All Answers
Try Below Test Class Made Some Change Please Mark It As Best Answer If It Helps Thank You!
This worked thank you so much for your help.