+ Start a Discussion

Install Issue : Validation Rules make my code coverage Failed


I have a test class that create a new Opportunity to work with. The problem is that some customers have their own validation rules in some of the Opportunity object, and cause the insert fail.



Opportunity newOppty = new Opportunity(StageName='Qualification', Probability=10, Amount=100.00, Type='Existing Customer - Downgrade', LeadSource='Web', IsPrivate=false, Name='John Bess Oppty', ForecastCategoryName='Pipeline', CloseDate=Date.today());
insert newOppty;


 There is a way to know if there are any validation rule on the opportunity fields before the insert and create a valid Opportunity?? What is the best practice in this case?, because I can't what the users can have differents validations depend of each Org. 


Thanks in advance,