Some Salesforce developers like to write automated tests with "SeeAllData=True", an outdated and bad practice. A test that can see all data is not the same as a test that is smart enough to see the data that needs testing. For example, a good test will test positive scenarios, negative scenarios and extremes. In other words:
- What if the data is exactly what we planned for -- records with all the right data in all the right places?
- What if the data falls outside of expected norms -- records with missing fields or invalid data, for example?
- What if the data is coming in from a data import operation or an integration and many records need to be processed?
Note that you will want to use data that corresponds to the configuration changes that you are testing. In this example, configuration changes and business process automation around Account, Contact and Opportunity record creation will be tested. You can create a similar test class for other related objects, including custom objects.
This code can be run as a unit test by itself to validate configuration changes, or it can be called by other test code to set up data for more complex unit testing related to other code in the org.
Next week, I will look into some of the errors that might occur when you create CSV files of sample data and how to avoid those errors.
But for now, Auntie Pat Tern has a point, who wants Superman looking at just any old thing with his x-ray vision when he ought to be focusing on information that's most helpful.
You can find sample files here: https://gist.github.com/snugsfbay/c48c399b8d5e32561e5fdc91a770eef5
ReplyDelete