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
Chinmay AbhangraoChinmay Abhangrao 

test classs in not wrking and giving error like this anybody help/..

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ProdTrackOnAcc: execution of AfterInsert  caused by: System.ListException: Duplicate id in list: 0016F00002OuVyiQAF  Class.trigger_helper.trigger_method_when_inserted: line 54, column 1 Trigger.ProdTrackOnAcc: line 10, column 1: []
bhanu_prakashbhanu_prakash
Hi Chinmay,
Mark as best answer, If it resloves !!
If its Production you're deploying to, you can't edit code in Production. You will have to "deploy" any and all code changes. Might be an idea to check with whoever put those validation rules in and who wrote those other tests. You might want to update the test classes and deploy - as they seem to be only simple data related validation errors.

Mark as resloved if it helps :) :)
Thanks, 
Bhanu Prakash
visit ForceLearn.com​​ ​ (https://www.forcelearn.com)


 
Akshay_DhimanAkshay_Dhiman
Hi Chinmay,

Please try the below code for the test class
 
Class Helper Class
{
Set<id> proSet=new Set<Product>();
public static void  myMethod(List<product2> proObj)
{
porSet.add(porObj.id);
}
List<product2> proList2=new List<product2>();

proList2=[SELECT
          Id,
    Name,
    ....,
    ....
    FROM Product
    WHERE id in:porSet;
          ];
 if(proList2.size()>0)
 {
      insert proList2;
    } 
}

if you found this answer helpful then please mark it as best answer so it can help others.   
  
  Thanks 
  Akshay