• M-H
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi Every1,

 

I know many of you might seen this error before.

 

Failure Message: "System.ListException: List index out of bounds: 0", Failure Stack Trace: "Class.UserGroupTest.testuseradd: line 22, column 1"

 

Can someone help me resolve this perticular error. 

 

 

 

@istest
class UserGroupTest {

static testmethod void testuseradd(){

    test.starttest();
    List<Account> a= [Select Id From Account Where Name LIKE 'ABC%' Limit 1];

    List<Contact> c1 = [Select Id From Contact Where AccountId=:a[0].Id];
    
    List<Profile> p = [Select Id From Profile Where Name='** Custom: Portal: XYZ Partner'];
    
    if (p.size() > 0) {
        User u = new User(Username='test@teest.org',
         LastName='My Test',
          Alias='mmtt',
           CommunityNickname='tt11',
            TimeZoneSidKey='America/Los_Angeles',
             LocaleSidKey='en_US',
              EmailEncodingKey='UTF-8',
               LanguageLocaleKey='en_US',
               IsActive=true,
                ContactId=c1[0].Id, ProfileId=p[0].Id, email='test@teest.org');
        insert u;
    }
    test.stoptest();
    
    }
}

  • January 04, 2013
  • Like
  • 0