You need to sign in to do that
Don't have an account?
Royal
@IsTest(SeeAllData=true) ?
when i use SeeAllData=true on test class, can able to query the records from org, and able to insert, update but not able to delete, why ?
see the below test class after delete statement assert statement is failing, can you please look into this .....
@IsTest(SeeAllData=true)
private class TestClassOnVenkat{
static testmethod void InsertRec(){
venkat__c a=[select id,name from venkat__c where name='name value'];
Venkat__c b=a.clone();
b.name='cloneed name value';
Test.startTest();
insert b;
venkat__c c=[select id,name from venkat__c where name='cloneed ZZZZZ'];
System.assert(c != Null);
c.name='Update name value';
update c;
System.assert(c.name=='cloneed name value');
delete c;
System.assert(c == null);
Test.stopTest();
}
}
Thanks
see the below test class after delete statement assert statement is failing, can you please look into this .....
@IsTest(SeeAllData=true)
private class TestClassOnVenkat{
static testmethod void InsertRec(){
venkat__c a=[select id,name from venkat__c where name='name value'];
Venkat__c b=a.clone();
b.name='cloneed name value';
Test.startTest();
insert b;
venkat__c c=[select id,name from venkat__c where name='cloneed ZZZZZ'];
System.assert(c != Null);
c.name='Update name value';
update c;
System.assert(c.name=='cloneed name value');
delete c;
System.assert(c == null);
Test.stopTest();
}
}
Thanks
you're deleting the record. The variable is still set.
Try to replace the last assert with:
All Answers
Since test methods don’t commit data created in the test, you don’t have to delete test data upon completion.
For more info ,please refer https://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#CSHID=apex_testing.htm|StartTopic=Content%2Fapex_testing.htm|SkinName=webhelp
Let us know if it helps you.
you're deleting the record. The variable is still set.
Try to replace the last assert with:
your right, now passing the test class,
i have two more doublts can you pls clarify me
1. but what is reason for that, i mean only list records can we able to delete or we can not able to delete set and individual records ?, is it that means ?
2. and one more is if use SeeAllData=true that class or method can have access org data, so i think we cannot perform the DML operations on org data but we can able here, is there any imfact on org Data ? if not why ?
thanks you so much for your reply.
1. You can either delete list of record or individual record. Your code is correct. It wasn't correct only the last System.assert. When you delete a record (or list of records), the variable that contains that record (or list) is still populated. So, if you check the value of a variable after a delete operation, it is still "!= null".
2. No, there are no impacts on org data, because the test classes don't commit the DML operations, also with the "SeeAllData=true" annotation.
Let me check if it is all clear now.
Bye
what the main purpose of having seealldata=true in the test class.Could you please explain withone example.?
Thanks