[SalesForce] Test class error while insert a record

I'm trying to insert a record under Account using test class as follows

List< Account> c = new List <Account>(NameLocal='test44',Name='testprimary',Industry='Aerospace');
insert c;

Error: Compile Error: expecting a right parentheses, found ',' at line 10 column 61

Best Answer

You are getting mixed up with the List and the Account. You should be creating the List first and then adding the Account into it as shown here:

List< Account> accounts = new List <Account>();
accounts.add(new Account(NameLocal='test44',Name='testprimary',Industry='Aerospace'));
insert accounts;

Alternatively, if you wanted to do it without the List you could do:

Account account = new Account(NameLocal='test44',Name='testprimary',Industry='Aerospace');
insert account;
Related Topic