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
Chris MarzellaChris Marzella 

What is wrong with this simple test class?

@IsTest
public class TestNewUser{
    static TestNewUserMethod void insertLead(){
    
    Lead l = new Lead();
    
    l.FirstName = 'Apex';
    l.LastName = 'Trigger';
    l.Company = 'Admins Who Code';
    l.LeadStatus = 'Open - Not Contacted';
    
    insert l;
    }

}
[Error] Error: Compile Error: unexpected token: 'insertLead' at line 3 column 34
Best Answer chosen by Chris Marzella
Shashikant SharmaShashikant Sharma
@IsTest
public class TestNewUser{
    static TestMethod void insertLead(){
    
        Lead l = new Lead();
        
        l.FirstName = 'Apex';
        l.LastName = 'Trigger';
        l.Company = 'Admins Who Code';
        l.Status = 'Open - Not Contacted';
        
        insert l;
    }

}
Use this method. In your case you were two mistakes

1. use of TestNewUserMethod 
2. l.LeadStatus as field API name is Status so i change dit to l.Status

Thanks
Shashikant

All Answers

Shashikant SharmaShashikant Sharma
@IsTest
public class TestNewUser{
    static TestMethod void insertLead(){
    
        Lead l = new Lead();
        
        l.FirstName = 'Apex';
        l.LastName = 'Trigger';
        l.Company = 'Admins Who Code';
        l.Status = 'Open - Not Contacted';
        
        insert l;
    }

}
Use this method. In your case you were two mistakes

1. use of TestNewUserMethod 
2. l.LeadStatus as field API name is Status so i change dit to l.Status

Thanks
Shashikant
This was selected as the best answer
Chris MarzellaChris Marzella
Thanks you Shashikant. I thougt "TestMethod" was a variable. Thus beign able to name it anything. I guess Iwas wrong in that thinking!
Shashikant SharmaShashikant Sharma
Hi Chris,

TestMethod is sort of identifier for a method that it is a method that will be run when you hit Run Test on a apex class.
If above helped you then please select as Answer so it could benifit others if they face same issue.

Thanks
Shashikant