You need to sign in to do that
Don't have an account?
salesforcerrr
Simple Test Class for SOQL Query in Apex
Hi,
would need assistance for getting started with testing apex classes. I basically created a simple class that is just a SOQL query returning a list of accounts owned by a given user:
so far so good and all working well in sandbox but after searching and trying to find just some simple test class in order to achieve code coverage... the best i end up with is something like:
which still gives me two problems:
1. Constructor not defined: [AccountRemoter].<Constructor>(ApexPages.StandardController)
2. I think I would need some asserts below but i really cannot find a post where there is a simple test class
Could someone guide me in the redirection and if this has been answered before please guide me in the right direction. After hours I am still unable to locate a solution.
Thanks
would need assistance for getting started with testing apex classes. I basically created a simple class that is just a SOQL query returning a list of accounts owned by a given user:
global with sharing class AccountRemoter { @RemoteAction global static List<Account> findAll() { return [SELECT Id, Owner.Name, Name, Phone, Email__c, ShippingLatitude, ShippingLongitude FROM ACCOUNT WHERE OwnerId=:UserInfo.getUserID()]; } }
so far so good and all working well in sandbox but after searching and trying to find just some simple test class in order to achieve code coverage... the best i end up with is something like:
@isTest class AccountsListControllerTest { static testMethod void testAccountList (){ List<Account> accounts = new List<Account>(); for (Integer count = 0; count < 50; count++) { accounts.add(new Account (Name = 'Jack'+count, Phone ='00000000'+count)); } insert accounts; AccountRemoter cc = new AccountRemoter(new ApexPages.StandardController(new Account())); Test.startTest(); cc.findAll(); Test.startTest(); } }
which still gives me two problems:
1. Constructor not defined: [AccountRemoter].<Constructor>(ApexPages.StandardController)
2. I think I would need some asserts below but i really cannot find a post where there is a simple test class
Could someone guide me in the redirection and if this has been answered before please guide me in the right direction. After hours I am still unable to locate a solution.
Thanks
use this
Please choose as best answer
Thanks
All Answers
use this
Please choose as best answer
Thanks
welcome
please choose as best answer