You need to sign in to do that
Don't have an account?
Chiyan
test code for below one
public class AccountController {
@AuraEnabled
public static List<Account> getLimitedAccounts(){
List<Account> accounts = [SELECT Id, Name, Phone
FROM Account ORDER BY CreatedDate LIMIT 20];
return accounts;
}
}
@AuraEnabled
public static List<Account> getLimitedAccounts(){
List<Account> accounts = [SELECT Id, Name, Phone
FROM Account ORDER BY CreatedDate LIMIT 20];
return accounts;
}
}
Try the below test class:
@isTest
public class AccountControllerTest {
static testmethod void AccountContest ()
{
List<Account> accList = new List<Account>();
Account acc1 = new Account(name='Test Account', Phone='1234567890');
Account acc2 = new Account(name='Test Account1', Phone='1234567891');
Account acc3 = new Account(name='Test Account2', Phone='1234567892');
accList.add(acc1);
accList.add(acc2);
accList.add(acc3);
insert accList;
Test.startTest();
AccountController.getLimitedAccounts();
Test.stopTest();
}
}
Can you please Let me know if it helps or not!!!
If it helps don't forget to mark this as a best answer!!!
Thanks,
Maharajan.C
Please try this code:
@isTest
private class AccountController{
@isTest static void testController(){
List<Account> acList=new List<Account>();
Account ac=new Account();
ac.name='test account';
acList.add(ac);
insert acList;
Test.startTest();
AccountControllerTest.getLimitedAccounts();
Test.stopTest();
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha