• JimDeLong
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
In a testMethod, can I dynamically instantiate a page's controller?

I have a page, p1, which has a controller c1, and I write the testMethod to give me a page ref off of p1, and the controller from c1 to c2 - could the testMethod have been written to figure that out?

I could envision a solution where if I were sometimes using c1 and sometimes using c2, so I could have if statements determine which to instantiate.

But I would need to know this up front if I were going to use this approach in a managed package. If the user of the system were to add c3 after I built the package - then I wouldn't be able to accomodate it.

I'm writing a post install script to populate custom objects. How does it impact code coverage? Do I just call the class.method() in the testMethod script?

Will the entries be scanned? Will there be a 75% code coverage requirement?

I need one final Mobile Expert to help on our team. If you know of someone who is very good & may not even be interested, urge her or him to contact me: botzcontrol@gmail.com ... this is a new gendre of software. See the trailer for the movie 'her'.

I'm writing a post install script to populate custom objects. How does it impact code coverage? Do I just call the class.method() in the testMethod script?

I need one final Mobile Expert to help on our team. If you know of someone who is very good & may not even be interested, urge her or him to contact me: botzcontrol@gmail.com ... this is a new gendre of software. See the trailer for the movie 'her'.

We're getting many questions about how to add or drop someone from the team you registered with for the hackathon. Per the rules and regulations, you're allowed one change prior to teams locking on November 19th. If you'd like to make a change please email us at info@developerforce.com with the names of the team members you are adding or dropping. We'll need their names, email addresses, and registration number for Dreamforce - either from a Hacker Pass or a conference registration.

I'm a visual designer interested in collaborating on a cool mobile app

Developed post install script -- no problem.

However, when I try to add a test script (see below), I get "Method does not exist or incorrect signature: System.Test.testInstall". The testInstall method does not show up in the list of methods available for the Test class in Eclipse IDE, and editing/saving the test class directly in the Salesforce UI results in the same error.

Please advise.

 

@isTest
static void testInstallScript() {
PostInstallClass postinstall = new PostInstallClass();
System.Test.testInstall(postinstall, null);
System.Test.testInstall(postinstall, new Version(1,0), true);
List<Account> a = [Select id, name from Account where name ='Newco'];
System.assertEquals(a.size(), 1, 'Account not found');
}

Hello,

 

I am trying to insert a feedComment of contentcomment type on a feedpost in the follwing test method- 

when i run the test i get an error  saying "System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: []"

 

static testmethod void mytest(){
        Account Acc = new Account(Name = 'TestAccountBhushan',Phone = '040-754-7845');
        insert acc;  
        
        contentVersion cv = new contentVersion(
        pathonclient = 'My Document.docx',
        versionData = EncodingUtil.base64Decode('SampleImageFile')
        );
        insert cv;   
        //Inserting  post on chatter
        FeedItem textFeed = new FeedItem(
                Body = 'This is a text post',
                Type = 'TextPost',
                ParentId = acc.id               
        );          
        insert textFeed;
        
        FeedComment fc = new FeedComment(
            feedItemId = textFeed.Id,
            relatedRecordId = cv.id,
            commentBody = 'Test Comment Body'
            //commentType = 'ContentComment'
        );   
        insert fc;
        system.debug('****** Comment******'+ fc);

}

 

Thanks,

Bhushan