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
Nisse Knudsen.ax1026Nisse Knudsen.ax1026 

Creating TestCoverage for ContentDocument trigger not possible?

Hey! :)

 

I added a ContentDocument trigger via Force.com IDE und wanted to include this trigger in my managed package.

I create a test method that should fire my trigger, which then calls a trigger handler class.

 

Now the problem:

 

Whe I run the test class, I see as a result, that 80-ish% of my trigger handler code has been covered. This means, the trigger did definitely fire!! But I can't see this trigger in the result list.

But the biggest problem is, that the packaging process aborts everytime with the reason, that the ContentDocument trigger has 0% test coverage.

 

I don't know what to do, it just appears to me, that the ContentDocument trigger has not been fully integrated by SFDC?

 

Any help is appreciated!

 

Best Regards,

 

Nisse

imranrazaimranraza

Hi Nisse Knudsen,

You can use this code of Test Method for your Trigger

private class TestClass{

@isTest

private static void runTest(){

ContentVersion contentVersionObj = new ContentVersion();
contentVersionObj.ContentURL='http://www.google.com/';
contentVersionObj.Title = 'Google.com';            
insert contentVersionObj;

}

}

PchawlaPchawla

Hi All,

 

I want to write a trigger on chatter file upload . so when a user upload a file , if file size is greater than 10 MB then it should throw an error message . please help, it would be a great help if you could send me a code example.

Apex_LearnerApex_Learner

How does one go about generating a ContentDocument trigger?  I could use one if it were avaialble, but can't seem to discover how to do it in the Setup screens...

 

Does this only apply to specific licenses?

 

 

SydneyForceSydneyForce

I believe you cannot create a ContentDocument trigger from the UI or setup page. You instead need to the Force.com IDE.

 

For more details, see theSpring '12 Force.com Platform Release ContentDocument Triggers Notes:

 

http://developer.force.com/releases/release/Spring12/contentdocument+triggers

 

Kai Wifi AmundsenKai Wifi Amundsen
I am having the same issue. It seems that ContentDocument and ContentVersion triggers do not fire in a Unit Test context.  Can anyone confirm this?  I can't even find an ideas to confirm it is a known limitation.