I need to test the following piece of code:

if (ApexPages.currentPage().getUrl().contains('ActiveParticipant'))
    Tab1Style = 'activeTab';

How can I set the URL so that the condition evaluates to true?

//If your page is "ActiveParticipant" do as follows   
PageReference pageRef = Page.ActiveParticipant;
| improve this answer | |
  • Thanks! Your code helped me to figure it out. What I used was actually this: PageReference pageRef = new PageReference('/apex/ActiveParticipant'); Test.setCurrentPage(pageRef); – anwarabq May 16 '15 at 20:32

Try below code:

String baseURL = ApexPages.currentPage().getUrl();

if(baseURL.contains('ActiveParticipant')){ Tab1Style = 'activeTab'; }

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.