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
Proposal ButtonProposal Button 

Error in my test class

Hi

 

I am trying to write a test class for the following controller. Here is my controller

 

public class CAFApprovalHistoryController {
    public String cafId {get;set;}
    public List<ProcessInstanceHistory> getApprovalSteps() {
      If (cafId != null) {
        CAF__c cafs = [Select Id, Name, CAPEX_Total__c, Off_Net_Circuit_Expense_Total__c, CAF_IRR__c, of_Revisions__c, Sales_Rep__c, Sales_Manager__c, Account__c, CAF_Title1_del__c, CAF_1__c, Products_Requested__c, Bandwidth__c, Notes_of_Consideration__c, CAF_Link__c, (Select TargetObjectId, SystemModstamp, StepStatus, RemindersSent, ProcessInstanceId, OriginalActorId, IsPending, IsDeleted, Id, CreatedDate, CreatedById, Comments, ActorId From ProcessSteps order by SystemModstamp desc) from CAF__c where Id = :cafId];
        return cafs.ProcessSteps;
      }
      return new List<ProcessInstanceHistory> ();
    } 
   }

 

Here is the test class i wrote and this the error it is throwing Error: Compile Error: line breaks not allowed in string literals at line 8 column -1. I mentioned the line 8 in Red

 

 

public class TestCAFApprovalHistory
{
    public static testMethod void testCAFApprovalHistory() 
         {      
        Test.startTest();
        PageReference result = Page.CAFApprovalHistory;
        Test.setCurrentPage(result);               
        CAF__c cf = new CAF__c(Name='Test', CAPEX_Total__c='$1000.00', Off_Net_Circuit_Expense_Total__c='$1000.00, CAF_IRR__c='25%', of_Revisions__c='0', Sales_Rep__c='Test', Sales_Manager__c='TestTest', Account__c='Test Account');
        insert cf;
        }
        }

 

mikefitzmikefitz

Remove the line break and make those two lines one. Sometime I have to copy the code into notepad and copy it back in. HIdden characters sometimes get added if your copied and pasted from a third party application (word, IE, FF, etc).

Good Luck

 

Mike

hermihermi

Looks like you missed a quote for this value:

Off_Net_Circuit_Expense_Total__c='$1000.00, 

replace this with below line

Off_Net_Circuit_Expense_Total__c='$1000.00', 

 

Thanks

Vinay Marru

Proposal ButtonProposal Button

 

Hi Vinay
Thanks for the reply. Now it is saying that CAFApprovalHistory page does not exist.click here to crete a page. My question i know that there is no page on this name but i am trying to point out to my component. Actually i have a component called CAFApprovalHistory component. Can you please direct me how should i need to pint out to my component. I mentioned in the red color below in red that is point towards a page. I want to point it towards component.
public class TestCAFApprovalHistory
{
    public static testMethod void testCAFApprovalHistory() 
         {      
        Test.startTest();
        PageReference result = Page.CAFApprovalHistory;
        Test.setCurrentPage(result);               
        CAF__c cf = new CAF__c(Name='Test', CAPEX_Total__c='$1000.00', Off_Net_Circuit_Expense_Total__c='$1000.00, CAF_IRR__c='25%', of_Revisions__c='0', Sales_Rep__c='Test', Sales_Manager__c='TestTest', Account__c='Test Account');
        insert cf;
        }
        }