You need to sign in to do that
Don't have an account?

Why this test class can be executed correctly
Hi Guy,
I have a wierd problem about apex test class, code shows below:
@isTest
private with sharing class testcls {
static testMethod void testMethod1() {
Account a = new Account();
a.Id = '0017F00000hZblNQAS';
update a;
}
}
i didn't add seealldata annotation in this test class, '0017F00000hZblNQAS' is a real account record in my sandbox.
In my understanding, test classes will run in virtual environment, if we don't add seealldata annotation, we can't access to any real data in sandbox, but why my code can be executed and no issue?
Somebody can give me an explanation?
I have a wierd problem about apex test class, code shows below:
@isTest
private with sharing class testcls {
static testMethod void testMethod1() {
Account a = new Account();
a.Id = '0017F00000hZblNQAS';
update a;
}
}
i didn't add seealldata annotation in this test class, '0017F00000hZblNQAS' is a real account record in my sandbox.
In my understanding, test classes will run in virtual environment, if we don't add seealldata annotation, we can't access to any real data in sandbox, but why my code can be executed and no issue?
Somebody can give me an explanation?
Greetings!
The test class is getting saved without any errors However,when you try to run the test class you might see the errors since you can't insert the value on the Id field as it is system generated by default whenever the new record is inserted.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri