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
マスターキートン!マスターキートン! 

SObject新規作成時にMapパラメータで生成したいです

@IsTest
public with sharing class TestDataHelper {

    public static SObject createAccount(Map<String, Object> parameterValues) {
        Map<String, Object> defaultValues = new Map<String, Object>{
                'name' => 'Test Account'
        };

        Account a = new Account(map_merge(defaultValues, dataValues));  ←ここでSobjectのパラメータとしてMapわたせませんか?
        insert a;
        return a;
    }

    private static Map<String, Object> map_merge(Map<String, Object> data1, Map<String, Object> data2) {
        Map<String, String> result = data1;
        for(String key : data2.keySet()) {
            result.put(key, data2.get(key));
        }
        
        return result;
    }

}


お世話になっております。

TestDataをつくるクラスをつくっているのですが、

Account a = new Account(); ←ここでSobjectのパラメータとしてMapわたせませんでしょうか。