You need to sign in to do that
Don't have an account?
Roelof Wal
test custom class, where to start?
I have a custom class which needs testing but I have no clue how to and where to get started.
Below is an example of the original.
This code is used on a custom Apex page to generate some output.
My questions:
Below is an example of the original.
This code is used on a custom Apex page to generate some output.
public with sharing class getCustomvalues { private final Account account; public List<String> myitems {get; private set;} public List<Account_items__c> result {get;set;} public getCustomvalues() { Id id = ApexPages.currentPage().getParameters().get('id'); account = [SELECT Account.Name, items__c FROM Account WHERE Id = :id]; myitems = new List<String>(); if (account.items__c== null) { /* code */ } else { /* code */ } } public Account getAccount() { return account; } }
My questions:
- How to instantiate this class from a testing class?
- How to set the currentPage Id ?
- Should I use a stub class too?
Try Below Test Class Please Mark It As Best Asnwer If It Helps
Thank You!
All Answers
Try Below Test Class Please Mark It As Best Asnwer If It Helps
Thank You!
Now I write the tests, this put me in the right direction.