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
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);
                 if(listOrderItem.size()==0)
                  {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+'\'';}
                  listOrderItems.clear();
                  listOrderItems=Database.query(orderItemQuer);
                  listOrderItem.add(new OrderItem(Id=listOrderItems[0].Id,OrderId=(String)inputMap.get('ContextId'),Tet_Serial_Number__c=prdSrlNum));
                 }update listOrderItem;}
pconpcon
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.