You need to sign in to do that
Don't have an account?
help on custom controller test method
Hi
Finally learned how to write test methods. But it looks like the code coverage is not enough. I got 55% code coverage. Please giude me how to cover the rest.
When i run the tests i got the following lines are not covered. I am not getting any idea of how to write. please guide...thanks
Code Not Covered
Class |
10 |
16 | ||
|
Class |
12 |
21 | |
|
Class |
13 |
16 | |
|
Class |
14 |
21 | |
|
Class |
15 |
16 | |
|
Class |
16 |
21 | |
|
Class |
17 |
16 | |
|
Class |
19 |
16 | |
|
Class |
31 |
21 | |
|
Class |
33 |
25 | |
|
Class |
35 |
21 | |
|
Class |
36 |
21 | |
|
Class |
38 |
21 |
public class Travelling_Redirect
{
DateTime t;
List<Travelling__c> tvt;
public PageReference init()
{
User us=[Select TIMEZONESIDKEY from User where id=:UserInfo.getUserId()];
{
if(us.TIMEZONESIDKEY=='America/New_York' || us.TIMEZONESIDKEY=='America/Panama')
t=System.Now();
else if(us.TIMEZONESIDKEY=='America/Chicago' || us.TIMEZONESIDKEY=='America/El_Salvador')
t=System.Now()+1;
else if(us.TIMEZONESIDKEY=='America/Denver' || us.TIMEZONESIDKEY=='America/Phoenix')
t=System.Now()+2;
else if(us.TIMEZONESIDKEY=='America/Los_Angeles' || us.TIMEZONESIDKEY=='America/Tijuana')
t=System.Now()+3;
else
t=System.Now();
}
tvt=[select place, redemption_date__c from Travelling__c where expiration_date__c>=:t and SFDC_ID__c=:UserInfo.getUserId() limit 1];
Integer count= tvt.size();
return redirectTest(count,tvt);
}
public PageReference redirectTest(Integer count,List<Travelling__c> tvt)
{
PageReference myPR = null;
DateTime resu;
if(tvt.size()>0)
{
for(Travelling__c t:tvt)
{
resu=t. redemption_date__c;
}
if(resu==null)
myPR=Page.Travelling_Home;
else
myPR=Page. Travelling _AlreadySelected;
}
else
myPR = Page.Travelling_No_Places;
if (myPR != null)
myPR.setRedirect(true);
return myPR;
}
public static testMethod void results()
{
Travelling_Redirect test=new Travelling_Redirect();
test.init();
}
}