+ Start a Discussion
Pranav S SanvatsarkarPranav S Sanvatsarkar 

Bypassing client required fields, valiadtion rules while running test classes for package installation/upgrade

Hello there,

I have a managed package, and my clients are installing it on their instances. However, my test classes fail due to their customization like required fields or validation rules. Is there any standard way so that the installation can be done without any issue?

Thanks in advance!
Pranav S SanvatsarkarPranav S Sanvatsarkar
Hello Karthikeyan,

I am not using any deployment tool. I have two developer editions. One is where I create managed package. On the other instance, I install the created managed package. Now, if I have made some fields on Account as required (custom fields) or applied validation rules on those custom fields, how would I be able to install or upgrade the package on the other instance?

Hi Pranav Trailblazer,

Did you find a solution to the problem you were facing with your managed package test classes failing due to configurations specific within the client's Org?

Kind Regards,
Pranav S SanvatsarkarPranav S Sanvatsarkar
Hello Swarna,

The only solution I found is not running test classes at the time of installation/upgrade. There is no any feasible way to bypass validation rules or required fields as we cannot handle the same in our test classes during packaging. @isTest(onInstall=false) or simple @isTest would tell the platform not to run the specified classes during installation or upgrade.

The force.com platform is smart enough that it reads and understands our codebase and validates the end user's instance specific config to make sure every piece of our code works after installation/upgrade.

Hope my research helps you!