function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mallikammallikam 

testing pagereferences in assertEquals

I have the following code in one of the controller extension methods:

 

confirm() { 

PageReference p = Page.offbsubmit;

p.setRedirect(true);

return p;

}

 

I am testing the above code in testMethod using the following statement..

 

PageReference q = test.confirm();

PageReference s = Page.offbsubmit;

system.assertEquals(q, s); // getting an exception here!!

 

I am getting the following exception:

 

System.Exception: Assertion Failed: Expected: System.PageReference[/apex/offbsubmit], Actual: System.PageReference[/apex/offbsubmit] 

 

which doesnt make anysense to me because the expected and the actual values are the same..any help?

 

Message Edited by mallikam on 07-28-2009 11:10 AM
Best Answer chosen by Admin (Salesforce Developers) 
thangasan@yahoothangasan@yahoo

Hai

 

You can chk like below

 

system.assertEquals(q.getURL(), s.getURL());

 

Regards

Thanga

All Answers

thangasan@yahoothangasan@yahoo

Hai

 

You can chk like below

 

system.assertEquals(q.getURL(), s.getURL());

 

Regards

Thanga

This was selected as the best answer
Volker_factory42Volker_factory42
That's awesome! It works fine! :smileyhappy: