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
jimmy_sfjimmy_sf 

Testing apex code paths which require some KnowledgeArticleVersions

Hi,

 

I've got a good amount of apex code which is only executed when some draft KnowledgeArticleVersions exist.  I understand that we cannot create KnowledgeArticleVersions from apex coce, so I'm not sure how to get test coverage on that code which requires presence of draft KnowledgeArticleVersions.

 

Despite the presece of knowledge article drafts in my (prerelease) org, none are present in the test context.

 

Is there some way to work around these restrictions to get test coverage?

 

Best,

-jimmy 

jimmy_sfjimmy_sf

I've now figured out how to create a draft KnowledgeArticleVersion (of article type basic):

 

basic__kav kbv = new basic__kav(Title = 'test', UrlName = 'test' , Language = 'es' );  

insert kbv;

 

I am not able to create KnowledgeArticleVersion drafts which reference the inserted KnowledgeArticleVersion. MasterArticleID and IsMasterLanguage are not writable fields on insert.

 

I'm unable to write tests againt apex code which deals with the translation KnowledgeArticleVersions of a given master KnowledgeArticleVersion.  

 

Are there any workarounds here?

 

Best,

-jimmy