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
farah sheriffarah sherif 

I need help with a test class can anyone help

@isTest

private class AssetTriggerTest{
    @testSetup 
     static void testclass(){
         List<sObject> ls = Test.loadData(Asset.sObjectType, 'AssetTest2');
        List<sObject> lsa = Test.loadData(Account.sObjectType, 'AccountTestF');

         
    }
    
    public static testMethod void test(){

       Map<id,Asset> a = New Map <id, Asset >([select Product_Family__c , Status from Asset ]);
       List<Asset> l = a.values();
        for( Asset ast:l){
            
            if(ast.Product_Family__c == '360'){
                
                ast.Status = 'Canceled';
            }
        }
        update l;
        
        Account acc=[select Account_Status__c from Account limit 1];
        system.assertEquals(acc.Account_Status__c,'Cancel');
       
        
    }

    
}




it's giving me this error :
System.StringException: Error in CSV resource 'AssetTestF' line 2: Cannot set the value of a calculated field
Best Answer chosen by farah sherif
Raj VakatiRaj Vakati
Your code looks good but the issue is the data in an AccountTestF.csv file which uploaded to static resource .. The file looks like contains some of the read-only fields like Formula fields or created date etc .. 

Please delete those read-only fields from the csv file and run the test class