You need to sign in to do that
Don't have an account?
Test class
Hi,
public void view()
{
aid=apexpages.currentpage().getparameters().get('conname');
con=[select id,lastname,name,phone,email,Department,Mailingcity,Mailingstreet,Mailingcountry,Mailingpostalcode,accountid from contact where id=:aid];
}
How to call view() in test class am calling following way am getting Error
System.QueryException: List has no rows for assignment to SObject Stack Trace Class.Contactview.view: line 30, column 1
Class.Contactview.Test: line 115, column 1
========This is my test method=========
@isTest
Static void Test()
{
account a=new account(name='acc');
insert a;
contact c=new contact();
c.lastname='suresh';
c.firstname='reddy';
c.phone='8899887778';
c.email='test@test.com';
c.Department='sales';
c.Mailingcity='Hyd';
c.Mailingstreet='anand nagar';
c.Mailingcountry='india';
c.Mailingpostalcode='500082';
c.accountid=a.id;
insert c;
if(c.id!=null)
{
apexpages.currentpage().getparameters().put('Id',c.id);
}
Contactview con=new Contactview();
con.getcontactpage();
con.view();
con.getconview();
}
Thanks in Advance
You need to make one change,
apexpages.currentpage().getparameters().put('conname',c.id);
Thanks,
Devendra
All Answers
You need to make one change,
apexpages.currentpage().getparameters().put('conname',c.id);
Thanks,
Devendra
Hi Devendra,
It is working, Thanks for your reply.
Thank you