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
MichalMichal 

Failing PKB test classes - deployment no longer possible

Hello,
I have problem with third party unmanaged package(s) pkb_* - Public Knowledge Base. It contains errors in test classes: pkb_Test and pkb_mobile_Test - their unit tests fail. In both the cases (classes) problem seems to be with method:
populatePKB2Environment() and code:
String q = 'select ' +pkb_Controller.join(pkb_Controller.kavFields, ',')+ ' from KnowledgeArticleVersion where Id = \'' +kavObj.get('Id')+ '\' and PublishStatus = :publishStatus';
kavObj = (KnowledgeArticleVersion)Database.query(q);
The error message is "System.QueryException: List has no rows for assignment to SObject"
I tried to fix them but seems that they are non-writeable. Additionally the package lowers overall coverage to 58% so I'm not able to deploy any chnages e.g. to my. triggers which are correct and have coverage about 90%.
As far as I know Public Knowledge Base is in use and this time cannot be just uninstalled.
How can I make any changes to my triggers and test classes in such situation? (I tried Force.com eclipse plugin, developers console as well as incoming/outgoing packages method)
BTW, how was it possible to install the package if its unit tests failed?
Regards,
Michal

Best Answer chosen by Admin (Salesforce Developers) 
wahoobiewahoobie
If you have set a 'standard' Article Type (via App Setup / Customize / Knowledge / Article Types to no longer be 'Deployed' you can fail on the canned Tests Classes. Ensure the Test class refers to a currently deployed Article Type or revising the test class should address this.

Good luck in your efforts!

All Answers

sfdcfoxsfdcfox
The most usual cause of failures in code in a production environment is due to modifications made to the organization metadata after the code was tested. For example, changing some settings, adding validation rules, etc, can cause a previously passed test to fail. You'll have to fix the problems before you can deploy your trigger code changes. There's no way to "bypass" this feature or test "just your code" (the system wouldn't know how to distinguish between your code and not-your code in an unmanaged package scenario anyways...).
MichalMichal

Thanks but it is too general. I need help with this particular app/package - PKB. I think the probleam appears whenver it is installed (probably just stock classess without extra customization). Previously it was just removed and I was able to continue changes in my triggers but this time the Knowledge Base cannot be unistalled because it is in use.

Maybe I still need some provileges? I'm already "Knowledge User" and I was granted with "Artilce Manager" permission but perhaps there is something more necessary?

Michal

 

sfdcfoxsfdcfox
Can you link me the app on the appexchange? I'd be glad to take a look and see if there's something unusual going on. Normally, I'd say that deployments should generally be done by a user with the "System Administrator" profile when possible, but as long as you have Publish Apex and Customize Application, I can't see generically why this would fail.
wahoobiewahoobie
If you have set a 'standard' Article Type (via App Setup / Customize / Knowledge / Article Types to no longer be 'Deployed' you can fail on the canned Tests Classes. Ensure the Test class refers to a currently deployed Article Type or revising the test class should address this.

Good luck in your efforts!
This was selected as the best answer
MichalMichal

sfdcfox wrote:
Can you link me the app on the appexchange? I'd be glad to take a look and see if there's something unusual going on. Normally, I'd say that deployments should generally be done by a user with the "System Administrator" profile when possible, but as long as you have Publish Apex and Customize Application, I can't see generically why this would fail.
 

The app name is: "Public Knowledge for Mobile, Web and Facebook" (ver 3.1). The Appexchange link is, I believe: https://appexchange.salesforce.com/listingDetail?listingId=a0N300000059QxXEAU

Michal

MichalMichal

wahoobie wrote:
If you have set a 'standard' Article Type (via App Setup / Customize / Knowledge / Article Types to no longer be 'Deployed' you can fail on the canned Tests Classes. Ensure the Test class refers to a currently deployed Article Type or revising the test class should address this.

Good luck in your efforts!

Thank you very much wahoobie! That was the solution. I had to temporarily change deployment status of two article types from "In Development" to "Deployed" becasue the broken unit tests are read only for me and it helpd.

Best Regards,

Michal

wahoobiewahoobie
You are very welcome, we hit it in our initial rollout earlier this year :)

Chris