You need to sign in to do that
Don't have an account?
Nick Powell
System.debug stops working after DML inside of test coverage that works fine
Hi,
I'm writing test coverage for a trigger that, by all other accounts, is working fine, and yet the system.debug messages just seem to stop working after certain DML calls (as you can see below I'm obviously trying to assess a SOQL query limit problem). In the code below the debug logs show all of the system.debugs *except* for the very last one just after the final dml update. What sort of thing could be causing this? I get no error messages in any of the logs, the Test Coverage is running fine, the code runs fine ... This method inserts fine but breaks on the update, and I have another method that breaks on the insert. Certainly there might be some specific problem buried in the trigger but I'd like a general sort of lead before digging into that because I have absolutely no *sense* of *how* to start sniffing right now.
Opportunity testOpp1 = new Opportunity ();
testOpp1.RecordTypeId = giftInKindRecordTypeId;
testOpp1.Name = 'TestGIK1';
testOpp1.AccountId = donorAcct.Id;
testOpp1.StageName = 'Received';
testOpp1.CloseDate = System.Now().Date();
testOpp1.Goal_Credit_Date__c = System.Now().Date();
testOpp1.GIK_Fund__c = 'General Fund';
testOpp1.GIK_Entity__c = 'Stand for Children, Inc. (C3)';
testOpp1.GIK_Community__c = 'Gresham';
testOpp1.InKind_Estimated_Value__c = 50;
testOpp1.Description = 'random text';
System.debug('Total Number of SOQL Queries just before inserting: ' + Limits.getQueries());
insert testOpp1;
System.debug('Total Number of SOQL Queries after inserting: ' + Limits.getQueries());
testOpp1.StageName = 'Pending';
update testOpp1;
System.debug('Total Number of SOQL Queries - pending: ' + Limits.getQueries());
testOpp1.StageName = 'Received';
//update testOpp1;
System.debug('Total Number of SOQL Queries - received again but not updated: ' + Limits.getQueries());
testOpp1.StageName = 'Pending';
update testOpp1;
System.debug('Total Number of SOQL Queries - pending again: ' + Limits.getQueries());
testOpp1.StageName = 'Received';
update testOpp1;
System.debug('Total Number of SOQL Queries - received again AND updated: ' + Limits.getQueries());
Test.stopTest();
Thanks!
Nick
I'm writing test coverage for a trigger that, by all other accounts, is working fine, and yet the system.debug messages just seem to stop working after certain DML calls (as you can see below I'm obviously trying to assess a SOQL query limit problem). In the code below the debug logs show all of the system.debugs *except* for the very last one just after the final dml update. What sort of thing could be causing this? I get no error messages in any of the logs, the Test Coverage is running fine, the code runs fine ... This method inserts fine but breaks on the update, and I have another method that breaks on the insert. Certainly there might be some specific problem buried in the trigger but I'd like a general sort of lead before digging into that because I have absolutely no *sense* of *how* to start sniffing right now.
Opportunity testOpp1 = new Opportunity ();
testOpp1.RecordTypeId = giftInKindRecordTypeId;
testOpp1.Name = 'TestGIK1';
testOpp1.AccountId = donorAcct.Id;
testOpp1.StageName = 'Received';
testOpp1.CloseDate = System.Now().Date();
testOpp1.Goal_Credit_Date__c = System.Now().Date();
testOpp1.GIK_Fund__c = 'General Fund';
testOpp1.GIK_Entity__c = 'Stand for Children, Inc. (C3)';
testOpp1.GIK_Community__c = 'Gresham';
testOpp1.InKind_Estimated_Value__c = 50;
testOpp1.Description = 'random text';
System.debug('Total Number of SOQL Queries just before inserting: ' + Limits.getQueries());
insert testOpp1;
System.debug('Total Number of SOQL Queries after inserting: ' + Limits.getQueries());
testOpp1.StageName = 'Pending';
update testOpp1;
System.debug('Total Number of SOQL Queries - pending: ' + Limits.getQueries());
testOpp1.StageName = 'Received';
//update testOpp1;
System.debug('Total Number of SOQL Queries - received again but not updated: ' + Limits.getQueries());
testOpp1.StageName = 'Pending';
update testOpp1;
System.debug('Total Number of SOQL Queries - pending again: ' + Limits.getQueries());
testOpp1.StageName = 'Received';
update testOpp1;
System.debug('Total Number of SOQL Queries - received again AND updated: ' + Limits.getQueries());
Test.stopTest();
Thanks!
Nick
All Answers