In one of my test classes, I want an opportunity to persist across all the testmethods. how do I do that? Also, is that a best practice when it comes to apex?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
You can not persist values across testmethods and is bad practice to do so. SFDC rolls back all updates at the conclusion of a testmethod
Instead, if you need an Opportunity in each testmethod, consider loading it with the Apex statement using a common-to-all testmethods mockEnv() method which you can query for in each testmethod and use as needed