You need to sign in to do that
Don't have an account?

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;
}
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;
}
}
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);
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;
}