You need to sign in to do that
Don't have an account?

Need Help Creating Test Class...
I am new to Apex, and the testing has me a bit confused as to how to perform certain types of tests:
Below is my code, can some one help me see how to write a test for this as well as answer the questions below?
1. How to test a method that is defined as a PageReference? (i.e how to CALL it in a test method?)
2. When creating test data "on the fly" how long does the test data stay available (i.e If I create test data in the FIRST test method, is the data gone right after that test completes or is that test data available to all the rest of the test methods I have defined. So Can I just add the test data ONCE, for ALL my tests or do I need to do it for EACH test method I have defined?
public PageReference processViewHousehold() {
//Householdis is a PUBLIC variable contains list of id's
if(householdid != null)
{
List<Account> HouseHold = new List<Account>(
[
Select id
from account
where payout__Households__c = :householdid
]
);
List<Id> myClientIdList = new List<id> ();
for(Account a : HouseHold){
myClientIdList.add(a.id);
}
ClientIdList = myClientIdList;
}
return null;
}
Data you create for unit tests exists only for the lifetime of the test method. You can write a helper method that creates test data, then call the method from each of your test methods.
Thanks...
But first the link you gave doesn't seem to exist anymore ("Got the dreaded OOps.... message")
Secondly, I have read some testing articles already, but I haven't seen any examples of how to test a method defined as a PageReference data type.
So if someone can please provide me with a testing method example of a PageReference method I would really appreciate it.
Not sure what is happening but the link you are giving me is saying "Oops not found"...
If general, you can find these documents via developer.force.com