You need to sign in to do that
Don't have an account?
Error in Test.startTest() method
hello
i am using test,startTest() and test.stopTest() method in test class.
i am facing a error :
Method does not exist or incorrect signature: Test.startTest() at line 16 column 9
my code is :
@isTest
private class testclass{
public static testMethod void TestOverwriteTestAccountDescriptions(){
// Perform our data preparation.
List<Account> accounts = new List<Account>{};
for(Integer i = 0; i < 200; i++){
Account a = new Account(Name = 'Test Account ' + i);
accounts.add(a);
}
// Start the test, this changes governor limit context to
// that of trigger rather than test.
Test.startTest();
// Insert the Account records that cause the trigger to execute.
insert accounts;
// Stop the test, this changes limit context back to test from trigger.
Test.stopTest();
// Query the database for the newly inserted records.
List<Account> insertedAccounts = [SELECT Name, Description
FROM Account
WHERE Id IN : accounts];
// Assert that the Description fields contains the proper value now.
for(Account a : insertedAccounts){
System.assertEquals(
'This Account is probably left over from testing. It should probably be deleted.',
a.Description);
}
}
}
I think you have another apex class caleed "Test". That's why you are getting this error. Check for it.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
All Answers
Try
instead of
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
I think you have another apex class caleed "Test". That's why you are getting this error. Check for it.
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.
thanks for reply
now i have solved this problem.
actually a apex class named as test is alredy exist.
now i rename that class.
my code is working now
Yeah, If you want to keep your class called Test, then you have to use System.Test.startTest()
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.