I have a class which has a method with a parameter of JSON type. Now my goal is to create a Test class to test the method with the parameter of JSON. Please see my codes.

This is my method in my myClass:

public static void createAccount(CT_Part result){

Here is my Test Class method:

@isTest static void createAccountTest(){


This are my sample Data JSON which I will use to test the method from my test class.

{'record':{'sourceSystemIdentifier':'System Administrator',

How will I test my method using the sample JSON data.

1 Answer 1


If I understood well, you have to deserialize your sample data into you object (using Json.Deserialize method), and then call your test function as usual

cf : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm#apex_class_System_Json

  • Thank you very much, that's it all I need is the keyword :) thanks for helping me Apr 12, 2019 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .