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
SwkannanSwkannan 

Error while installing package

Hello

 

We created an unmanaged package in the Dev Org and  tried installing the Package in our Test Org but I get this error and installation fails.

 

Apex Classes(01pU0000000HqgO)System.Exception: Assertion Failed: Expected: 0, Actual: 1
Class.TEST_Relationships.TestOrphanedRelDelete: line 179, column 3
External entry point



If I select Ignore Apex Test Failures then my package installs succesfully.



When I ran the tests in the Developer Org the code passes all  the tests.

 

Can someone let me know why this might be happening??

 

\I would like to know if it is ok to select Ignore Apex Test Failures during installation as I read that it is not best practice.

 

 

Thank you

 

 

 

ReidCReidC

Need to see the code to be sure.

Usually what happens for me in this case is that the packaging org has one set of data assumptions and your test org has another.  Your test then doesn't narrow it's expected results enough to meet whats in your packaging org.  

How to fix: update your test to be more explicit about the data it's testing for.  

SwkannanSwkannan

Thank you for your quick response.

 

I have included the Test class below.

Could you tell me where we are going wrong with this??

 

Thank you

 /// <name> TestOrphanedRelDelete </name>
  /// <summary> test method for relationships and deleting the mirror record </summary>
  static testMethod void TestOrphanedRelDelete() {  
    Contact firstContact = new Contact (
      FirstName='Joe',
      LastName='Johanssen'
    );
    insert firstContact;

    Contact secondContact = new Contact (
      FirstName='Bobby',
      LastName='Johanssen'
    );
    insert secondContact;

    Relationship_Type__c firstRelType = new Relationship_Type__c (
      Name='&&Test_Relationship 1'
    );
    
    Relationship_Type__c secondRelType = new Relationship_Type__c (
      Name='&&Test_Relationship 2',
      Reverse_Relationship_Name__c = firstRelType.Id
    );
    
    firstRelType.Reverse_Relationship_Name__c = secondRelType.Id;
    
    insert firstRelType;
    insert secondRelType;

    Relationship__c[] crel = new Relationship__c[]{
      new Relationship__c(contact__c = firstContact.id, Relatedcontact__c = secondContact.id, Relationship_Type__c=firstRelType.Id)
    };
    insert crel;
    
    // check that rel gets created
    Relationship__c crel_original = [select id, Description__c,Relationship_Type__c,reciprocalrelationship__c from Relationship__c where id=:crel[0].Id];
    //relationship should be set right
    System.assertEquals(crel_original.Relationship_Type__c, firstRelType.Id);

    // check for mirror rel
    Relationship__c crel_mirror = [select id, Description__c, reciprocalrelationship__c, Relationship_Type__c from Relationship__c where reciprocalrelationship__c=:crel_original.Id];
    //mirror should reference the original
    System.assertEquals(crel_mirror.reciprocalrelationship__c, crel_original.Id);
    Contact secondContactForDelete = [select id from contact where id=:secondContact.id];
    Test.startTest();
    delete secondContactForDelete;
    Test.stopTest();
    // test change to the rel
    Relationship__c[] orphanedCrel = [select id from Relationship__c where id = :crel_original.Id];
    //original should have updated relationship
    System.assertEquals(0, orphanedCrel.size());
  }
}



Sridhar BonagiriSridhar Bonagiri

Hi,

 

I think nothing will happen if you select Ignore Apex Test Failures during installation, from Winter'12 release of Salesforce, while installing the package you will not see  'Ignore Apex Test Failures' option also.

 

Sridhar Bonagiri