Relax icon indicating copy to clipboard operation
Relax copied to clipboard

relax.UnitTests.TestSimpleProcessAdvancement -- System.AssertException: Assertion Failed: Expected: 30, Actual: 25

Open dvf1976 opened this issue 10 years ago • 1 comments

The error: relax.UnitTests.TestSimpleProcessAdvancement -- System.AssertException: Assertion Failed: Expected: 30, Actual: 25 seems to happen spuriously in our non-Prod environments (probably once every 15 runs-or-so).

It hasn't happened during a Prod release, yet... but when it does we will be sad because it'll invalidate a test run of over 5000 tests that takes ~2.5 hours to run.

I don't see how this test is failing... but it appears to be.

This is for the Managed Package v1.4

dvf1976 avatar Feb 12 '15 21:02 dvf1976

I've seen this on production and sandboxes a few times now, but very randomly. Seems to be some kind of race condition.

Here's the dummy data fetched on line 190 when the test fails: 12:43:36:398 USER_DEBUG [191]|DEBUG|dummyData = (Job__c:{Name=a1QO0000002k9haMAA, Run_Increment__c=30, Id=a1QO0000002k9haMAA}, Job__c:{Name=a1QO0000002k9hbMAA, Run_Increment__c=25, Id=a1QO0000002k9hbMAA}, Job__c:{Name=a1QO0000002k9hcMAA, Run_Increment__c=2, Id=a1QO0000002k9hcMAA}, Job__c:{Name=a1QO0000002k9hZMAQ, Run_Increment__c=30, Id=a1QO0000002k9hZMAQ})

And when it doesn't fail: 12:43:18:080 USER_DEBUG [191]|DEBUG|dummyData = (Job__c:{Name=a1QO0000002k9hPMAQ, Run_Increment__c=30, Id=a1QO0000002k9hPMAQ}, Job__c:{Name=a1QO0000002k9hQMAQ, Run_Increment__c=30, Id=a1QO0000002k9hQMAQ}, Job__c:{Name=a1QO0000002k9hRMAQ, Run_Increment__c=25, Id=a1QO0000002k9hRMAQ}, Job__c:{Name=a1QO0000002k9hSMAQ, Run_Increment__c=2, Id=a1QO0000002k9hSMAQ})

It looks like a combination of two problems:

  • Something in the original insert of dummy data results in the IDs being out of order
  • When the Name of the dummy data records is changed to the Id (UnitTestJob2), the fetched dummy data doesn't come back in the expected order.

I fixed it by replacing the code at line 190 with this: Map<Id,Job__c> updatedDummyDataMap = new Map<Id,Job__c>([select Id, Name, Run_Increment__c, Run_Units__c from Job__c where Id IN :dummyDataIds order by Name]); System.assertEquals(4,updatedDummyDataMap.size()); System.assertEquals(30,updatedDummyDataMap.get(dummyData[0].Id).Run_Increment__c); // was 3 minutes, so should now be 30 System.assertEquals(30,updatedDummyDataMap.get(dummyData[1].Id).Run_Increment__c); // was 4 minutes, so should now be 30 System.assertEquals(25,updatedDummyDataMap.get(dummyData[2].Id).Run_Increment__c); // WAS 25 minutes, so no update should have happened System.assertEquals(2,updatedDummyDataMap.get(dummyData[3].Id).Run_Increment__c); // WAS 2 hours, so no update should have happened

jeremyhiggs avatar Dec 20 '16 08:12 jeremyhiggs