+ Start a Discussion
angusgrantangusgrant 

Test Method Questions do you have to assume there is no test data in the system?

I am in the process of writing a test method in the developer version of Salesforce for a visualforce controller class that i have created.

 

The creation of which I have assumed there will be some test data in the system to work with?

 

When migrating my project accross to the Enterprise  version of the Salesforce system I am assuming that I can initailly import all my code into a sandbox version of my system... (without needing to pass the unit tests) and then input some test data which will allow the test methods to pass? Or should I rewrite my test methods in such a way  that no data(other than reference data) need be in the sytem. Also some of my reference data is held in its own Objects in the sytem can I package this up for the main export. Excuse theses newbie questions.  

MakMak
Test cases should be written keeping all scenarios in mind. So you should create dummy data within the test code if possible.
RajanJasujaRajanJasuja

 Hi,

 

Test method best practice says, create dummy data within the test code.Data created in test methods don’t commit in database and will not be reflected in any of the FSDC Org.So best practice is to create dummy data in the test method as per your code condition requirement.

 

When you are deploying the code from sandbox to production one fast bypass is to use the old records hardcode Ids to select the test data (Only those records Ids which exits in production and sandbox both, Because SFDC provides same Ids for same records in sandbox and production).This approach is only recommended when you need to make a urgent deployment otherwise creating runtime test data is the best approach.

 

Best Regards,

Rajan Jasuja