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
kevin.chileskevin.chiles 

Unexpected token "insert"

Hi,

 

I am having an issue with my test class not being able to save. the error I get is Unexpected token "insert"at line 16

 

Not sure why this is happening as this has never happened for this type of test class before.  Here is the code for the creation of an account and a custom object record called SPA

 

@isTest
public class triggerSPACRUD{
static testMethod void triggerSPACRUD(){
//insert account
account acc = new account(
acc.Name='test account');

insert acc;


SPA__c SPA = new SPA__c(
SPA.Recordtypeid= '012P00000004XHj',
SPA.Status__c = 'End User',
SPA.Dealer__c=acc.Id)
//fill all the required field and make sure your data passes the validation rules.
insert SPA;

}

 

kevin.chileskevin.chiles

Got it, 

 

No need to use the account insert as it is not needed on this object,  

 

@isTest
public class triggerSPACRUD{
static testMethod void triggerSPACRUD(){


SPA__c SPA = new SPA__c();
SPA.Recordtypeid= '012P00000004XHj';
SPA.Status__c = 'End User';

//fill all the required field and make sure your data passes the validation rules.
insert SPA;

}

}

amarcuteamarcute

Hi,

 

You are missing semi-colon after the line:

 

SPA__c SPA = new SPA__c(
SPA.Recordtypeid= '012P00000004XHj',
SPA.Status__c = 'End User',
SPA.Dealer__c=acc.Id)

 

Just add a semiclon. 

 

SPA__c SPA = new SPA__c(
SPA.Recordtypeid= '012P00000004XHj',
SPA.Status__c = 'End User',
SPA.Dealer__c=acc.Id);

sandeep@Salesforcesandeep@Salesforce

I have corrected code in red lines

 

@isTest
public class triggerSPACRUD{
static testMethod void triggerSPACRUD(){
//insert account
account acc = new account(
acc.Name='test account');

insert acc;


SPA__c SPA = new SPA__c(
Recordtypeid= '012P00000004XHj',
Status__c = 'End User',
Dealer__c=acc.Id);
//fill all the required field and make sure your data passes the validation rules.
insert SPA;

}