+ Start a Discussion
NewGirlNewGirl 

Test Case Trouble! Please Help

I run my test case (see below) and it only covers it 60%.  when I read the detailed output it doesn't look like the trigger is working?  thanks for your help!  After the test case I listed the debug log....

 

Also why do my System.assertEquals statement return : System.assertEquals(ANY, ANY) - instead of the value???

 

Thanks for your help!

Karen

 

@isTest
private class ConvertOppLIQtyTest{
    static testMethod void testOppLIQty(){
    
 
    
    //Setup the Account record
    Account a = new Account(Name = 'Test Account');
    a.Type = 'Customer';
    insert a;
    
    // Verify that the initial state is as expected
    a = [SELECT Name, Type
        FROM Account
        Where Id = :a.Id];
    System.assertEquals ('Customer', a.Type);
    
    // setup the Opportunity record
    
    String opportunityName = 'Test Opportunity';
    Opportunity o = new Opportunity(AccountId=a.Id, name=opportunityName, StageName='4 - Closed Won', CloseDate = Date.today(),PO_Number__c='999', Order_ID__c='999', opp_ship_to__c='017' );
                                    
    
    insert o;
    
    opportunity opp = [select name from opportunity where Id = :o.Id];
     System.assertEquals (opportunityname, opp.name);

//     ----------------------------------------

     // set up product2 and Verify that the results are as expected.
        Product2 p2 = new Product2(Name='AMS300',isActive=true);
        insert p2;
        Product2 p2ex = [SELECT Name FROM Product2 WHERE Id = :p2.Id];
        System.assertEquals('AMS300', p2ex.Name);
        
// set up PricebookEntry and Verify that the results are as expected.
        PricebookEntry pbe = new PricebookEntry(Pricebook2Id='01s700000002a7TAAQ', Product2Id=p2.Id, UnitPrice=99, isActive=true);
        insert pbe;
        PricebookEntry pbeex = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id ];
 //       System.assertEquals(standardPriceBookId, pbeex.Pricebook2Id);
        
// set up OpportunityLineItem and Verify that the results are as expected.
        OpportunityLineItem oli = new OpportunityLineItem(PriceBookEntryId=pbe.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99);
       
 
 //------------------------
        
            // set up product2 and Verify that the results are as expected.
        Product2 p2a = new Product2(Name='AMS305-10PK',isActive=true);
        insert p2a;
        Product2 p2exa = [SELECT Name FROM Product2 WHERE Id = :p2a.Id];
        System.assertEquals('AMS305-10PK', p2exa.Name);
        
// set up PricebookEntry and Verify that the results are as expected.
        PricebookEntry pbea = new PricebookEntry(Pricebook2Id='01s700000002a7TAAQ', Product2Id=p2a.Id, UnitPrice=99, isActive=true);
        insert pbea;
        PricebookEntry pbeexa = [SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbea.Id ];
//        System.assertEquals(standardPriceBookId, pbeexa.Pricebook2Id);
        
// set up OpportunityLineItem and Verify that the results are as expected.
        OpportunityLineItem olia = new OpportunityLineItem(PriceBookEntryId=pbea.Id, OpportunityId=o.Id, Quantity=1, TotalPrice=99);
       
           
    Test.startTest();
          insert oli;
          insert olia;
    Test.stopTest();


    
 
    }
}

 

---------------------------------DEBUG LOG----------------------------------------------------------------

21.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
09:52:36.086|EXECUTION_STARTED
09:52:36.086|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000001FRX|ConvertOppLIQtyTest.testOppLIQty
09:52:36.086|METHOD_ENTRY|[2]|01pQ00000001FRX|ConvertOppLIQtyTest.ConvertOppLIQtyTest()
09:52:36.086|METHOD_EXIT|[2]|ConvertOppLIQtyTest
09:52:36.086|DML_BEGIN|[10]|Op:Insert|Type:Account|Rows:1
09:52:36.213|DML_END|[10]
09:52:36.213|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|SELECT Name, Type
FROM Account
Where Id = :a.Id
09:52:36.219|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.219|METHOD_ENTRY|[16]|System.assertEquals(ANY, ANY)
09:52:36.219|METHOD_EXIT|[16]|System.assertEquals(ANY, ANY)
09:52:36.219|METHOD_ENTRY|[21]|Date.today()
09:52:36.220|METHOD_EXIT|[21]|Date.today()
09:52:36.220|DML_BEGIN|[24]|Op:Insert|Type:Opportunity|Rows:1
09:52:36.356|DML_END|[24]
09:52:36.356|SOQL_EXECUTE_BEGIN|[26]|Aggregations:0|select name from opportunity where Id = :o.Id
09:52:36.361|SOQL_EXECUTE_END|[26]|Rows:1
09:52:36.361|METHOD_ENTRY|[27]|System.assertEquals(ANY, ANY)
09:52:36.362|METHOD_EXIT|[27]|System.assertEquals(ANY, ANY)
09:52:36.362|DML_BEGIN|[33]|Op:Insert|Type:Product2|Rows:1
09:52:36.419|DML_END|[33]
09:52:36.419|SOQL_EXECUTE_BEGIN|[34]|Aggregations:0|SELECT Name FROM Product2 WHERE Id = :p2.Id
09:52:36.424|SOQL_EXECUTE_END|[34]|Rows:1
09:52:36.424|METHOD_ENTRY|[35]|System.assertEquals(ANY, ANY)
09:52:36.424|METHOD_EXIT|[35]|System.assertEquals(ANY, ANY)
09:52:36.424|DML_BEGIN|[39]|Op:Insert|Type:PricebookEntry|Rows:1
09:52:36.476|DML_END|[39]
09:52:36.476|SOQL_EXECUTE_BEGIN|[40]|Aggregations:0|SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbe.Id 
09:52:36.479|SOQL_EXECUTE_END|[40]|Rows:1
09:52:36.480|DML_BEGIN|[51]|Op:Insert|Type:Product2|Rows:1
09:52:36.492|DML_END|[51]
09:52:36.492|SOQL_EXECUTE_BEGIN|[52]|Aggregations:0|SELECT Name FROM Product2 WHERE Id = :p2a.Id
09:52:36.496|SOQL_EXECUTE_END|[52]|Rows:1
09:52:36.496|METHOD_ENTRY|[53]|System.assertEquals(ANY, ANY)
09:52:36.496|METHOD_EXIT|[53]|System.assertEquals(ANY, ANY)
09:52:36.496|DML_BEGIN|[57]|Op:Insert|Type:PricebookEntry|Rows:1
09:52:36.504|DML_END|[57]
09:52:36.504|SOQL_EXECUTE_BEGIN|[58]|Aggregations:0|SELECT Pricebook2Id FROM PricebookEntry WHERE Id = :pbea.Id 
09:52:36.507|SOQL_EXECUTE_END|[58]|Rows:1
09:52:36.507|METHOD_ENTRY|[1]|Test.Test()
09:52:36.507|METHOD_EXIT|[1]|Test
09:52:36.507|METHOD_ENTRY|[65]|system.Test.startTest()
09:52:36.508|METHOD_EXIT|[65]|system.Test.startTest()
09:52:36.508|DML_BEGIN|[66]|Op:Insert|Type:OpportunityLineItem|Rows:1
09:52:36.516|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000000KbX|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.516|METHOD_ENTRY|[7]|System.debug(ANY)
09:52:36.516|USER_DEBUG|[7]|DEBUG|INSIDE OPP FOR LOOP!!!
09:52:36.516|METHOD_EXIT|[7]|System.debug(ANY)
09:52:36.516|METHOD_ENTRY|[11]|System.debug(ANY)
09:52:36.516|USER_DEBUG|[11]|DEBUG|01uQ0000004gObvIAE
09:52:36.516|METHOD_EXIT|[11]|System.debug(ANY)
09:52:36.516|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Product2Id from PricebookEntry where id = :insertedlineitem.PricebookEntryId
09:52:36.519|SOQL_EXECUTE_END|[12]|Rows:1
09:52:36.519|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select productcode from product2 where id = :PBE.product2id
09:52:36.522|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.522|METHOD_ENTRY|[15]|System.debug(ANY)
09:52:36.522|USER_DEBUG|[15]|DEBUG|PROD CODE null
09:52:36.522|METHOD_EXIT|[15]|System.debug(ANY)
09:52:36.523|METHOD_ENTRY|[31]|System.debug(ANY)
09:52:36.523|USER_DEBUG|[31]|DEBUG|77
09:52:36.523|METHOD_EXIT|[31]|System.debug(ANY)
09:52:36.817|CUMULATIVE_LIMIT_USAGE
09:52:36.817|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.817|TESTING_LIMITS
09:52:36.817|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 2 out of 100
Number of query rows: 2 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 8 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.817|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.817|CUMULATIVE_LIMIT_USAGE_END

09:52:36.523|CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.605|DML_END|[66]
09:52:36.605|DML_BEGIN|[67]|Op:Insert|Type:OpportunityLineItem|Rows:1
09:52:36.610|CODE_UNIT_STARTED|[EXTERNAL]|01qQ00000000KbX|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.610|METHOD_ENTRY|[7]|System.debug(ANY)
09:52:36.610|USER_DEBUG|[7]|DEBUG|INSIDE OPP FOR LOOP!!!
09:52:36.610|METHOD_EXIT|[7]|System.debug(ANY)
09:52:36.611|METHOD_ENTRY|[11]|System.debug(ANY)
09:52:36.611|USER_DEBUG|[11]|DEBUG|01uQ0000004gObwIAE
09:52:36.611|METHOD_EXIT|[11]|System.debug(ANY)
09:52:36.611|SOQL_EXECUTE_BEGIN|[12]|Aggregations:0|select Product2Id from PricebookEntry where id = :insertedlineitem.PricebookEntryId
09:52:36.613|SOQL_EXECUTE_END|[12]|Rows:1
09:52:36.613|SOQL_EXECUTE_BEGIN|[13]|Aggregations:0|select productcode from product2 where id = :PBE.product2id
09:52:36.618|SOQL_EXECUTE_END|[13]|Rows:1
09:52:36.618|METHOD_ENTRY|[15]|System.debug(ANY)
09:52:36.618|USER_DEBUG|[15]|DEBUG|PROD CODE null
09:52:36.618|METHOD_EXIT|[15]|System.debug(ANY)
09:52:36.618|METHOD_ENTRY|[31]|System.debug(ANY)
09:52:36.618|USER_DEBUG|[31]|DEBUG|77
09:52:36.618|METHOD_EXIT|[31]|System.debug(ANY)
09:52:36.912|CUMULATIVE_LIMIT_USAGE
09:52:36.912|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.912|TESTING_LIMITS
09:52:36.912|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 17 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.912|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.912|CUMULATIVE_LIMIT_USAGE_END

09:52:36.619|CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]
09:52:36.665|DML_END|[67]
09:52:36.665|METHOD_ENTRY|[68]|system.Test.stopTest()
09:52:36.665|METHOD_EXIT|[68]|system.Test.stopTest()
09:52:36.959|CUMULATIVE_LIMIT_USAGE
09:52:36.959|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 7 out of 150
Number of DML rows: 7 out of 10000
Number of script statements: 28 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.959|TESTING_LIMITS
09:52:36.959|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 4 out of 100
Number of query rows: 4 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 18 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

09:52:36.959|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
09:52:36.959|CUMULATIVE_LIMIT_USAGE_END

09:52:36.665|CODE_UNIT_FINISHED|ConvertOppLIQtyTest.testOppLIQty
09:52:36.665|EXECUTION_FINISHED
09:52:38.311|CUMULATIVE_PROFILING_BEGIN
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for SOQL operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for SOSL operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for DML operations
09:52:38.311|CUMULATIVE_PROFILING|No profiling information for method invocations
09:52:38.311|CUMULATIVE_PROFILING_END

Best Answer chosen by Admin (Salesforce Developers) 
alexbalexb

Well, the debug log will only show the values in an assert statement if the assert fails. It is printing the method signature of the method that is being called, and doesn't include the parameter values.

 

According to the log, a trigger called "convertOppLIqty" is executed on the OpportunityLineItem object:

CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]

All Answers

alexbalexb

Well, the debug log will only show the values in an assert statement if the assert fails. It is printing the method signature of the method that is being called, and doesn't include the parameter values.

 

According to the log, a trigger called "convertOppLIqty" is executed on the OpportunityLineItem object:

CODE_UNIT_FINISHED|convertOppLIqty on OpportunityLineItem trigger event BeforeInsert for [new]

This was selected as the best answer
NewGirlNewGirl

THANKS!!!