SOQL Lib Mocking
java
2 months ago
915 B
1
Indexable
Never
public with sharing class ExampleController { public static List<Account> getPartnerAccounts(String accountName) { // Your additional logic here return SOQL_Account.query() .byRecordType('Partner') .byName(accountName) .with(Account.BillingCity, Account.BillingCountry) .mockId('ExampleController.getPartnerAccounts') .toList(); } } @IsTest private class ExampleControllerTest { @IsTest static void getPartnerAccounts() { List<Account> accounts = new List<Account>{ new Account(Name = 'MyAccount 1'), new Account(Name = 'MyAccount 2') }; SOQL.setMock('ExampleController.getPartnerAccounts', accounts); // Test List<Account> result = ExampleController.getPartnerAccounts('MyAccount'); Assert.areEqual(accounts, result); } }