You need to sign in to do that
Don't have an account?
i am unable to cover test coverage for this class please help me
public with sharing class mainreports_class {
list<selectoption> v=new list<selectoption>();
public list<selectoption>getGetvalues() {
v.add(new selectoption('Select','--Select Rport--'));
v.add(new selectoption('FR Performance report based on Month','FR Performance report based on Month'));
v.add(new selectoption('MD Order Report','MD Order Report'));
v.add(new selectoption('Region Performance based on CBF','Region Performance based on CBF'));
v.add(new selectoption('Retailer Performance based on Month','Retailer Performance based on Month'));
return v;
}
public String selectedvalue { get; set; }
public String url{ get; set; }
User usr = [Select id,Alias,lastname,ContactId,Profile.name from User where id=:UserInfo.getUserId() Limit 1];
string prof=usr.Profile.name;
public void rpid() {
if(prof=='CMM East Profile')
{
if(selectedvalue =='FR Performance report based on Month')
{
url='/00Oa0000007nvM7?pv0=East&isdtp=nv';
}else
if(selectedvalue =='MD Order Report')
{
url='/00Oa0000007nvMb?pv0=East&isdtp=nv';
}else
if(selectedvalue =='Region Performance based on CBF')
{
url='/00Oa0000007nvMS?pv0=East&isdtp=nv';
}else
if(selectedvalue =='Retailer Performance based on Month')
{
url='/00Oa0000007nvMH?pv0=East&isdtp=nv';
}
}else if(prof=='CMM South Profile'){
if(selectedvalue =='FR Performance report based on Month')
{
url='/00Oa0000007nvM7?pv0=South&isdtp=nv';
}else
if(selectedvalue =='MD Order Report')
{
url='/00Oa0000007nvMb?pv0=South&isdtp=nv';
}else
if(selectedvalue =='Region Performance based on CBF')
{
url='/00Oa0000007nvMS?pv0=South&isdtp=nv';
}else
if(selectedvalue =='Retailer Performance based on Month')
{
url='/00Oa0000007nvMH?pv0=South&isdtp=nv';
}
}else if(prof=='CMM North Profile'){
if(selectedvalue =='FR Performance report based on Month')
{
url='/00Oa0000007nvM7?pv0=North&isdtp=nv';
}else
if(selectedvalue =='MD Order Report')
{
url='/00Oa0000007nvMb?pv0=North&isdtp=nv';
}else
if(selectedvalue =='Region Performance based on CBF')
{
url='/00Oa0000007nvMS?pv0=North&isdtp=nv';
}else
if(selectedvalue =='Retailer Performance based on Month')
{
url='/00Oa0000007nvMH?pv0=North&isdtp=nv';
}
}
else if(prof=='CMM West Profile')
{
if(selectedvalue =='FR Performance report based on Month')
{
url='/00Oa0000007nvM7?pv0=West&isdtp=nv';
}else
if(selectedvalue =='MD Order Report')
{
url='/00Oa0000007nvMb?pv0=West&isdtp=nv';
}else
if(selectedvalue =='Region Performance based on CBF')
{
url='/00Oa0000007nvMS?pv0=West&isdtp=nv';
}else
if(selectedvalue =='Retailer Performance based on Month')
{
url='/00Oa0000007nvMH?pv0=West&isdtp=nv';
}
}
}
}
my test class:
my test class
@istest(seealldata=true)
public class testmainreports_class
{
public static testmethod void test1()
{
mainreports_class c=new mainreports_class();
c.getGetvalues();
c.rpid();
}
}
public String prof{get;set;}
User usr = [Select id,Alias,lastname,ContactId,Profile.name from User where id=:UserInfo.getUserId() Limit 1];
prof=usr.Profile.name;
public static testmethod void test1()
{
mainreports_class c=new mainreports_class();
c.getGetvalues();
c.prof='CMM East Profile';
c.selectedvalue ='FR Performance report based on Month';
c.rpid();
c.selectedvalue =='MD Order Report'
c.rpid();
//Like this do for all. Using so many if conditions is not a good coding standard.
}
Thank you very much bro given ur valuable information......
and if u don`t mine please tell me which is the best way to write that code.......
<a href=http://www.computerbild.de/download/SoundFrost-8118785.html >youtube downloader</a>
Let me know if you face any issues.
Please mark it as solution and give Kudos if it helped you.
Hi, actually utold that Using so many if conditions is not a good coding standard. thats why i am asking there is any another way to write the code in a bestway.
e.g. - 00Oa0000007nvMS
As of now I think this code will do, but if in future you need to add more if conditions then create records in some object with fields like "Report Name" and "URL".
Fetch all the records and store it in a Map<String,Map<String,String>>.
then just one line
url=mapname.get(profilename).(selectedvalue);
Done :)