You need to sign in to do that
Don't have an account?
Damon Long
SOQL Query Test Class Issue
Hey all,
I am having an issue with my test class I have created. I am only getting 44% code coverage with my test class and I am not sure why. Any help would be greatly appreciated.
Apex Class:
Test Class:
I am having an issue with my test class I have created. I am only getting 44% code coverage with my test class and I am not sure why. Any help would be greatly appreciated.
Apex Class:
public class AssignedAdvisorController { @AuraEnabled public static User getAssignedAdvisor(Id recordId){ Account account = [select Assigned_Adviser__c from Account where Id=: recordId]; User user = [select Name, Phone from User where Id=: account.Assigned_Adviser__c]; return User; } @AuraEnabled public static String getAdvisorPhone(Id recordId){ Account account = [select Assigned_Adviser__c from Account where Id=: recordId]; User user = [select Phone from User where Id=: account.Assigned_Adviser__c]; String advisorPhone = user.Phone; return advisorPhone; } }
Test Class:
@isTest private class AssignedAdvisorControllerTest{ @testSetup static void setupTestData(){ test.startTest(); User user_Obj = new User(FirstName = 'Test', LastName = 'User'); Account account_Obj = new Account(Name = 'Test User', Assigned_Adviser__c = user_Obj.id); Insert account_Obj; test.stopTest(); } static testMethod void test_getAssignedAdvisor(){ test.startTest(); List<Account> account_Obj = [SELECT Id,Name,Assigned_Adviser__c from Account]; System.assertEquals(true,account_Obj.size()>0); AssignedAdvisorController obj01 = new AssignedAdvisorController(); AssignedAdvisorController.getAssignedAdvisor('01p90000006uk2w'); test.stopTest(); } static testMethod void test_getAdvisorPhone(){ test.startTest(); List<Account> account_Obj = [SELECT Id,Name,Assigned_Adviser__c from Account]; System.assertEquals(true,account_Obj.size()>0); AssignedAdvisorController obj01 = new AssignedAdvisorController(); AssignedAdvisorController.getAdvisorPhone('01p90000006uk2w'); test.stopTest(); } }
All Answers