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

testMethod doesn't recognize Account or custom obj - unexpected token error

Hi all,

I have a working trigger which I'm trying to write a testMethod for in Eclipse.

I have created a new class to put the testMethod in, but I am getting an error 'unexpected token SFDC_Special_Event__c' here is my code:

public class aTest {

    static testMethod void test_dupeBooking
  SFDC_Special_Event__c myBooking = new SFDC_Special_Event__c(Name='one');
  //SFDC_Special_Event__c[] bks = new SFDC_Special_Event__c[] { bk1 };
  //insert bks;


 I also get the error if I change SFDC_Special_Event__c to the standard Account object. It seems none of the objects are being recognized. What am I missing? I can see the custom object in the project treeview.


Fixed that problem I missed the () off the end of the testMethod declaration.

Now when I run the test, I get an error - see screenshot. Is this error because of a validation rule? I have validation rules and required fields, my testMethod only defines a 'Name' for the inserted obj.
Problem solved, it was partly the validation rules.
Can you share the trigger test class? I am ahving writing a test for a trigger Thanks