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
Diane Clayton 6Diane Clayton 6 

dx packaging version create apex test

Hi
When I try to create a new version of one of my dx packages with the code coverage flag it's failing on a unit test. I think this is because it needs to use a global value set in the dependent package. 

If I install my package in a new scratch org with it's 4 dependent packages that are listed in the sfdx-project.json then the unit tests all pass. Is there anyway to get around this?

 
VinayVinay (Salesforce Developers) 
Hi Diane, 

What is the error message you see?  For error 'Duplicate values' check below link.

https://help.salesforce.com/articleView?id=000316059&type=1&mode=1

Also, try to include a global value set and deploy or unplug the references from test class to avoid errors.

Hope this helps...

Thanks,
Diane Clayton 6Diane Clayton 6
Hi Vinay,
The error was in  a unit test error: INVALID_OR_NULL_FOR_RESTRICTED_PICKLISTO Code: invalid curre, Default Currency ISO Code: invalid currency code: GBP

This was because when  I created scratch org via powershell script be were adding in currencyType object so the unit tests all work. However when it runs test with -code coverage flag to create package version it doesn't have access to the currencyTypes. I hoped to fix this by adding them in test setup but currency type doesn't allow DML operation. So we can not add unit tests around these.

 
VinayVinay (Salesforce Developers) 
Good to know you found the route cause.  Check below references for details on INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST error.

https://www.ultrageek.com/?p=421
https://help.salesforce.com/articleView?id=000320321&type=1&mode=1

Thanks,