function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AffinaquestAffinaquest 

Managed Beta Package Installation Errors

I am getting a series of errors while installing my managed beta package in a test developer org.  They appear related to unit test routines that work perfectly prior to packaging and in the packaging process, but fail during the installation.  

 

If I check "Ignore Apex Errors" during the installation process, the installation proceeds normally.

 

Here is the type of error I'm getting:

Apex Classes(01pA00000023cDB) testemploymenttriggers.testEmploymentUpsert()
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AQB.AccountBeforeInsert: execution of BeforeInsert

caused by: System.QueryException: List has no rows for assignment to SObject

 

It looks like I'm getting an error similar to this while loading the package on every test class that I developed.

 

Any ideas of what's going on?

 

Thanks,

Jeff

 

aalbertaalbert

You are correct. That error is from one of your test methods failing upon install. The test methods are executed as part of the installation. And it appears that one of the SOQL queries within the method testEmploymentUpsert() is retrieved zero records and throwing an exception. When writing test methods, make sure you create the required data to complete the test since the installing org might not have data in the objects being queried. 

Aiden ByrneAiden Byrne

One thing to remember is that unit tests in your development organization may also run code that is not in your package. Code with a dependency is added to your package, but this isn't necessarily all your code.

 

I'm speaking for hard experience here. Over the weekend, I was having similar issues. It turns out that I forgot to include a required trigger with my package. The unit tests worked just find on my dev environment, but not in the managed package on a new install. Another potential gotcha is that you are depending on data in your dev org that is not created through your unit tests.

 

I've also had unusual cases where stuff that should break in my dev org doesn't, but breaks on deploy. I ran into this with where I was inserting a different picklist value but forgot to update the picklist settings to include the new value. It still worked in dev, but broke on deploy. 

 

One tip if you are still having issues - see if an unmanaged package fails. If it does, go ahead and tell Salesforce to ignore unit test failures on install. Then in the deployed environment, click "run all tests" for the Apex Classes. You should see the errors here. The nice thing is that you can now easily add debug statements etc to track down the root issue. Thats how I found the picklist problem I mention above.