0

I am using XML file in Static resources for unit testing. The controller class method validates the contents of XML file.I am passing XMLbody to method as string. When I ran the tests, the coverage is now 75%.

I have two questions

  1. Since I am using static resource file for testing, Shouldn't I include this file for migration to sandbox?
  2. I have hard coded data in XML file. For example, Authorization ID. This ID exists in database. XML file should have data for this authorization ID. When we move this file to other sandbox for testing, it may not work since authorization ID may not exist.This Authorization ID has been created from page functionality. So what is the methodology here to generate test Authorization ID and use it in XML so that it will not break testing in other sandbox.

Thank you very much

1 Answer 1

0
  1. Yes.
  2. Somewhere in your code replace the fields that vary with values taken from e.g. a custom setting. Have this mechanism working in both your dev org and sandbox so it is proven in the dev org first. If you want to do the substitution on the XML as a string add a distinct token that you are going to replace e.g. "@@@AuthorizationId@@@". If you do the substitution after the XML is parsed (a better approach) you can just match the element or attribute name.

You must log in to answer this question.

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