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
manjunath vivekmanjunath vivek 

Error: Compile Error: Method does not exist or incorrect signature: Test.startTest() at line 6 column 1

Iam trying to test the data to check if invoice with line item is not getting deleted, Iam getting above error.

@isTest
private class TestInvoiceStatementDeletion {
    static testmethod void TestDeleteInvoiceWithLineItem() {
// Create an invoice statement with a line item then try to delete it
Invoice_Statement__c inv = TestDataFactory.createOneInvoiceStatement(true);
Test.startTest();
Database.DeleteResult result = Database.delete(inv, false);
Test.stopTest();
// Verify invoice with a line item didn't get deleted.
System.assert(!result.isSuccess());
}
static testmethod void TestDeleteInvoiceWithoutLineItems() {
// Create an invoice statement without a line item and try to delete it
Invoice_Statement__c inv = TestDataFactory.createOneInvoiceStatement(false);
Test.startTest();
Database.DeleteResult result = Database.delete(inv, false);
Test.stopTest();
// Verify invoice without line items got deleted.
System.assert(result.isSuccess());
}
static testmethod void TestBulkDeleteInvoices() {
// Create two invoice statements, one with and one with out line items
// Then try to delete them both in a bulk operation, as might happen
// when a trigger fires.
List<Invoice_Statement__c> invList = new List<Invoice_Statement__c>();
invList.add(TestDataFactory.createOneInvoiceStatement(true));
invList.add(TestDataFactory.createOneInvoiceStatement(false));
Test.startTest();
Database.DeleteResult[] results = Database.delete(invList, false);
Test.stopTest();
// Verify the invoice with the line item didn't get deleted
System.assert(!results[0].isSuccess());
// Verity the invoice without line items did get deleted.
System.assert(results[1].isSuccess());
}
}
krupananda reddykrupananda reddy
Check once whether you org have an apex class named "Test". If it exists, rename the class. Let me know whether it helps.