+ Start a Discussion
Shubhangi JadhavShubhangi Jadhav 

How i can cover below lined in my test class:

                String prdName=(String)prodByNumbe.get('Name');
                String prdSrlNum=(String)prodByNumbe.get('value');
                String orderItemQuer;
                 system.debug('OrderItem' +orderItemQuer);
                  {orderItemQuer='SELECT Id FROM OrderItem WHERE OrderId='+'\''+inputMap.get('ContextId')+'\''+' AND Product2.Name='+'\''+prdName+'\'';}
                 else{orderItemQuer='SELECT Id FROM OrderItem WHERE OrderId='+'\''+inputMap.get('ContextId')+'\''+' AND Product2.Name='+'\''+prdName+'\''+' AND Id !='+'\''+listOrderItems[0].Id+'\'';}
                  listOrderItem.add(new OrderItem(Id=listOrderItems[0].Id,OrderId=(String)inputMap.get('ContextId'),Tet_Serial_Number__c=prdSrlNum));
                 }update listOrderItem;}
You'll find that you'll get a better response if you include any tests that you currently have.  This is a pretty simple thing to test using the test logic found in the introduction to testing modules on Trailhead.  Additionally, this is not show to be part of a controller, trigger or where it is being run from so not knowing any of that, it's almost impossible to write a test for this.

NOTE: Please use the "Add a Code Sample" button (icon <>) when adding code to make it easier to read and reference.