+ Start a Discussion
umesh atryumesh atry 

How do i achieve following line into Test Class

i want to coverage following lines to coverage into Test class.

   Id= Apexpages.currentPage().getParameters().get('delId2');
  productId= Apexpages.currentPage().getParameters().get('productId2');

Thanks in Advance.
 
Best Answer chosen by umesh atry
Sameer PrasonnSameer Prasonn
Hi Umesh,

There are two ways
1.
oppPage.getParameters().put('delId2',Product.Id);
oppPage.getParameters().put('productId2',Product.Id);
here we are adding parameter.

2.
if(!Test.isRunningTest()){
		   		Id= Apexpages.currentPage().getParameters().get('delId2');
		   		productId= Apexpages.currentPage().getParameters().get('productId2');
	   		}
by doing this we are exciptly providing parameter with class instance and skipping these steps.
you can cover use both the method. Please mark it as a best answer if it really help

Sameer B.

All Answers

Sameer PrasonnSameer Prasonn
Hi Umesh,

There are two ways
1.
oppPage.getParameters().put('delId2',Product.Id);
oppPage.getParameters().put('productId2',Product.Id);
here we are adding parameter.

2.
if(!Test.isRunningTest()){
		   		Id= Apexpages.currentPage().getParameters().get('delId2');
		   		productId= Apexpages.currentPage().getParameters().get('productId2');
	   		}
by doing this we are exciptly providing parameter with class instance and skipping these steps.
you can cover use both the method. Please mark it as a best answer if it really help

Sameer B.
This was selected as the best answer
umesh atryumesh atry
Oh sameer, You are Fabulos and Astonishing man.
Really, Your help is Excellent.
Thank You.