+ Start a Discussion
Shivani ThaparShivani Thapar 

Getting this error when trying to test my code...

Eror: Compile Error: unexpected token: 'List' at line 6 column 0

@isTest
private class myClass {
static testMethod void myTest() {
FindunpaidInvoices newInst = new FindunpaidInvoices();

List invoice = newInst.getUnpaidInvoices();
public class FindunpaidInvoices {
    private final List<Invoice_Consulting__c> invoices;

    public FindunpaidInvoices() {
        invoices = [select Account__c, Invoice_Date__c, Balance_Due__c from Invoice_Consulting__c where Name = 'Unpaid'];
    }

    public List<Invoice_Consulting__c> getUnpaidInvoices() {
        return invoices;
    }
}

Help please would be good thanks
 
YuchenYuchen
So in line 6, you can try replacing List with List<Invoice_Consulting__c>, because salesforce needs to know what type of Objects you want to put in the List.
Shivani ThaparShivani Thapar
did so, the error still occurs... thoughts?
YuchenYuchen
So you are still getting the same error or it is a different error now? If you are using "List<Invoice_Consulting__c>" then it should not throw error because that is what the getUnpaidInvoices returns in the FindunpaidInvoices class. You can also try deleting that line and adding "List<Invoice_Consulting__c> invoice = newInst.getUnpaidInvoices();" again.