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
Hanna BergsmaHanna Bergsma 

Help Writing Test Coverage on Simple Trigger!

I am not a coder and am looking to write test coverage for this simple trigger:
trigger ConDoc on ContentVersion (after insert) {

    List<ContentVersion> conver = [SELECT Id, Title, OwnerId FROM ContentVersion WHERE Id IN: Trigger.newMap.keySet()];

    for (ContentVersion CV: conver){
        CV.OwnerId= '005F0000002QTR2IAO';
        CV.Title = 'HannaTest';

    update conver;

Right now this is where I am at, I have no idea what I am doing. I appreciate any help. Im getting an Insert Failed when I run the Test
@isTest public class Test_ConDocTrigger {
static testMethod void TestData(){
    ContentVersion CV = new ContentVersion();       
	CV.OwnerId = '005F0000002QTR2IAO';
	CV.Title ='Test Name';
    insert CV;

AnudeepAnudeep (Salesforce Developers) 
Hi Hanna,

Providing sample test classes for contentversion here
private class ContentDocumentTest {
  private static testMethod void testCreate() {
    ContentVersion contentVersion_1 = new ContentVersion(
      Title = 'Penguins',
      PathOnClient = 'Penguins.jpg',
      VersionData = Blob.valueOf('Test Content')
      IsMajorVersion = true
    insert contentVersion_1;
    ContentVersion contentVersion_2 = [SELECT Id, Title, ContentDocumentId FROM ContentVersion WHERE Id = :contentVersion_1.Id LIMIT 1];
    List<ContentDocument> documents = [SELECT Id, Title, LatestPublishedVersionId FROM ContentDocument];
    System.assertEquals(documents.size(), 1);
    System.assertEquals(documents[0].Id, contentVersion_2.ContentDocumentId);
    System.assertEquals(documents[0].LatestPublishedVersionId, contentVersion_2.Id);
    System.assertEquals(documents[0].Title, contentVersion_2.Title);

Let me know if it gives you any coverage
Hanna BergsmaHanna Bergsma
Hi, Thanks for your response!
When running this the methods fail and i get 

"Error MessageSystem.DmlException: Insert failed. First exception on row 0; first error: INVALID_ARGUMENT_TYPE, The argument is null or invalid.: []
Stack TraceClass.Test_ConDocTrigger.testCreate: line 10, column 1"
Thank you for the useful information. I had trouble writing this problem at university. Also during this period I had to write a term paper on this topic. Therefore, I turned to the dissertation proposal writing service for help in order to have time to complete my assignments. Thanks to the experts, I managed to pass all my works to the teacher.
Keeran AdamsKeeran Adams
Research papers can be overwhelming with the amount of data and analysis required. I found an online essay writing service that specializes in research paper writing - Their writers are experienced in conducting in-depth research and analysis, and they provide well-structured and well-supported research papers that have helped me improve my academic performance.