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

Can any one help me how to write test class for this class?
id myProductId;
Public Document_Reference_Junction__c DocuRefIP { Get; Set; }
Hi
while running test classs , test method has failed it shows List has no rows for assignment to SObject. any one help me how to avoid this error. and this is my class.
public class sample{
public sample(){
DocuRefIP = New Document_Reference_Junction__c();
myProductId=ApexPages.CurrentPage().getParameters().get('Id');
DocuRefIP.Installed_Product__c=[select id from SVMXC__Installed_Product__c where id=:myProductId limit 1].id;
}
}
@isTest
public Class CSARevisePageForQuotePrpsalControlerTest {
public static testMethod void samTest() {
SVMXC__Installed_Product__c ip = new SVMXC__Installed_Product__c();
// enter the mandatory fields to insert sample test record
ip.name = 'test record';
insert ip;
Apexpages.currentpage().getparameters().put('id',ip.id);
ApexPages.StandardController con = new ApexPages.StandardController(ip);
sample sam = new sample(con);
}
}
@isTest
public Class CSARevisePageForQuotePrpsalControlerTest {
public static testMethod void samTest() {
SVMXC__Installed_Product__c ip = new SVMXC__Installed_Product__c();
// enter the mandatory fields to insert sample test record
ip.name = 'test record';
insert ip;
sample sam = new sample();
sam.myProductId = ip.id;
}
}
And one more thing is, why is the need of querying the Id when u are having the Id ??