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
s_foos_foo 

Getting Visualforce Error in ftest

Hi,

 

I am writing a f-test for an existing functional page in which  I am trying to get the page details but everytime I run my f-test its giving "VisualForce- Error". Plz find the code below

 

Any help on this is highly appreciated 

 

The contract insertion code is not adding here which is a part of ftest. 

 

static testMethod void testPageDetails(){

 

    PageReference ref = Page.TestPage;

     ref.getParameters().put('Id', contractId);

 

     String body = (ref.getContent()).toString();

     System.debug('***Details ::'+body)

 

 

}

 

Page

 

<apex:page controller="TestController" cache="false" title="FTest">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  This is your new Page :: {!contId}
  <!-- End Default Content REMOVE THIS -->
 
Billing Name : {!billingName}
</apex:page>

 

 

Controller

 

public class TestController {

String contId = null;
private Contract contract;

 

public TestController(){
contId = System.currentPageReference().getParameters().get('Id');

 
 this.contract = [Select BillingFirstName,BillingLastName
                  FROM Contract
                  Where Id = :contId];

}


public String getContId(){
 return contId;
}

public String getBillingName() {
 return contract.BillingFirstName+' '+contract.BillingLastName;
 }

}

 

P.S. The above Ftest works fine if I use the existing contract number from the App.