2

Hello,

I can't understand why this assertment is true in my DEV450 environment :

    // TODO #1: Review the code below to see how we are using  
    //          the assertEquals method of the System class to  
    //          ensure that there are no Contacts in the db.
    // System.debug('Size  : ' + [SELECT LastName FROM Contact].size());
    System.assertEquals(0, [SELECT LastName FROM Contact].size());

It seems to be true because the assertion pass, But I got contacts in my training environment !

enter image description here

Thanks

3

If this code is in a test class than it makes sense. At least as long as you do not use the annotation:

@isTest(SeeAllData=true)

In the test classes without this annotation you are just able to access/query the data that you create in your specific test method. The default value for this annotation is false.

  • I knew I was missing something enormous !! Thanks – Alexis MASSON Jun 29 '18 at 9:14
  • 1
    Setting the SeeAllData to true is supposed to be an exception for specific test cases (i.e. getting the standard pricebook before the Test.getStandardPricebookId was available). – Answers_Seeker Jun 29 '18 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.