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
Nick PowellNick 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
Best Answer chosen by Nick Powell
Nick PowellNick Powell
Downloading the raw log didn't help. The problem was with limits on log msg's, but I wasn't thinking about it correctly. It was the DML update before the system.debug that was itself filling the log with so much stuff that it couldn't get to the system.debug msg. I got around it by editing the log levels to give me basically nothing but the debugs on the apex.

All Answers

Biz ZaveriBiz Zaveri
If you are using the Developer Console, you can right-click on the Log and Open Raw Log or Download Log file.
Nick PowellNick Powell
Downloading the raw log didn't help. The problem was with limits on log msg's, but I wasn't thinking about it correctly. It was the DML update before the system.debug that was itself filling the log with so much stuff that it couldn't get to the system.debug msg. I got around it by editing the log levels to give me basically nothing but the debugs on the apex.
This was selected as the best answer