• koppinjo
  • NEWBIE
  • 25 Points
  • Member since 2013

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

I wrote a simple class, and have a test method which in the Force.com IDE is telling me covers this class 100%.  When I right-click on the class in the Package Explorer, go to Force.com > Deploy to server... I enter my production credentials and they are validated, then I see that only my class is set to add to the production environment and I go forward with the deployment.

After several minutes, I get a FAILURE message related to one test along the lines of 'too many DML rows', looking into the logs I see there are 10283 rows which exceeds the limit of 10000.  I log in to the production environment and run the failing test, and it fails in production too WITH THE SAME ERROR.

Now I have a chicken/egg situation and I don't know how to get any code to production with this failing test, and furthermore, I don't know how anything that would have broken this test would have made it to production!  I tried locally commenting out everything in the test class and the deployment failed in the exact same way (to the character) so I know it is not anything locally that I need to change.  I did have to fix some things in the test to get it to run locally, but that is irrelevant here especially since I commented the entire body out and got the same error.

HELP!!

Class I'm trying to deploy:

public class AuthorizationToken {

public String LoginId;

public String Password;

public AuthorizationToken(String user, String pw)

{

Password = pw;

LoginId = user;

}

statictestMethodvoid testAuthTokenInstantiation()

{

String user = 'testUser';

String pw = 'testPw';

Test.startTest();

AuthorizationToken testAuthToken = new AuthorizationToken(user, pw);

Test.stopTest();

System.assertEquals(testAuthToken.LoginId, 'testUser');

}

}

FAILING TEST CLASS:

@isTest
public with sharing class generateRenewalOppty_TEST
{
    static testMethod void myTest()
    {
        Boolean success = true;
       
       
           
            Account testAccount = new Account();
            testAccount.Name = 'Test';
            testAccount.Phone = '1111111111';
            testAccount.County__c = 'Macomb';
            testAccount.Member_Payment_Form__c ='Standard - Cash';
            testAccount.Type = 'Membership - New';
        
            insert testAccount;
           
            update testAccount;
           
            Product2 testProduct2 = new Product2(Name='TestProduct', ProductCode = '123', IsActive = true);
            insert testProduct2;
           
            List<Pricebook2> testPB2List = [select Id from Pricebook2 where IsStandard = true];
           
            PricebookEntry testPBE = new PricebookEntry(Product2Id = testProduct2.Id, Pricebook2Id = testPB2List[0].Id, UnitPrice = 5.0, UseStandardPrice = false, IsActive = true);
            insert testPBE;
           
           
            Opportunity oppObj = new Opportunity(Name='Test Opp',StageName='Closed Won - In-Kind',CloseDate=System.Today(),AccountId=testAccount.Id, type='Membership - New');
            insert oppObj;
           
            OpportunityLineItem testOPL = new OpportunityLineItem(OpportunityId = oppObj.Id, Quantity = 1.0, TotalPrice = 100, PricebookEntryId = testPBE.Id);
            insert testOPL;
           
            OpportunityLineItem testOPL1 = new OpportunityLineItem(OpportunityId = oppObj.Id, Quantity = 1.0, TotalPrice = 100, PricebookEntryId = testPBE.Id);
            insert testOPL1;
           
        
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
          
            Opportunity[] oppOpen =[Select Id,Amount from Opportunity Where (StageName='Open' or StageName='Membership - Renewal') and AccountId =:testAccount.Id];
            System.assertEquals(1, oppOpen.size());
          
            OpportunityLineItem[] oppLi =[Select Id,TotalPrice from OpportunityLineItem Where OpportunityId=:oppOpen[0].Id];
            System.assertEquals(2, oppLi.size());
            System.assertEquals(100, oppLi[0].TotalPrice);
            System.assertEquals(100, oppLi[1].TotalPrice);
           
            Opportunity[] oppRec = [Select Id from Opportunity];
            delete oppRec;
           
            Opportunity oppOb = new Opportunity(Name='Test Opp1',StageName='Open',CloseDate=System.Today(),AccountId=testAccount.Id);
            insert oppOb;
           
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
           
            Opportunity[] oppRec1 = [Select Id from Opportunity];
THIS IS LINE 52: delete oppRec1;
           
            Opportunity oppOb1 = new Opportunity(Name='Test Opp1',StageName='Open',CloseDate=System.Today(),AccountId=testAccount.Id,Type = 'Membership - New');
            insert oppOb1;
           
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
           
            //delete oppOpen;
                      
        }
 
}


TEST RESULT DETAIL:

Class: generateRenewalOppty_TEST

Method Name: myTest

Pass/Fail: Fail

Error Message: System.LimitException: Too many DML rows: 10001

Stack Trace: Class.generateRenewalOppty_TEST.myTest: line 52, column 1

 

I wrote a simple class, and have a test method which in the Force.com IDE is telling me covers this class 100%.  When I right-click on the class in the Package Explorer, go to Force.com > Deploy to server... I enter my production credentials and they are validated, then I see that only my class is set to add to the production environment and I go forward with the deployment.

After several minutes, I get a FAILURE message related to one test along the lines of 'too many DML rows', looking into the logs I see there are 10283 rows which exceeds the limit of 10000.  I log in to the production environment and run the failing test, and it fails in production too WITH THE SAME ERROR.

Now I have a chicken/egg situation and I don't know how to get any code to production with this failing test, and furthermore, I don't know how anything that would have broken this test would have made it to production!  I tried locally commenting out everything in the test class and the deployment failed in the exact same way (to the character) so I know it is not anything locally that I need to change.  I did have to fix some things in the test to get it to run locally, but that is irrelevant here especially since I commented the entire body out and got the same error.

HELP!!

Class I'm trying to deploy:

public class AuthorizationToken {

public String LoginId;

public String Password;

public AuthorizationToken(String user, String pw)

{

Password = pw;

LoginId = user;

}

statictestMethodvoid testAuthTokenInstantiation()

{

String user = 'testUser';

String pw = 'testPw';

Test.startTest();

AuthorizationToken testAuthToken = new AuthorizationToken(user, pw);

Test.stopTest();

System.assertEquals(testAuthToken.LoginId, 'testUser');

}

}

FAILING TEST CLASS:

@isTest
public with sharing class generateRenewalOppty_TEST
{
    static testMethod void myTest()
    {
        Boolean success = true;
       
       
           
            Account testAccount = new Account();
            testAccount.Name = 'Test';
            testAccount.Phone = '1111111111';
            testAccount.County__c = 'Macomb';
            testAccount.Member_Payment_Form__c ='Standard - Cash';
            testAccount.Type = 'Membership - New';
        
            insert testAccount;
           
            update testAccount;
           
            Product2 testProduct2 = new Product2(Name='TestProduct', ProductCode = '123', IsActive = true);
            insert testProduct2;
           
            List<Pricebook2> testPB2List = [select Id from Pricebook2 where IsStandard = true];
           
            PricebookEntry testPBE = new PricebookEntry(Product2Id = testProduct2.Id, Pricebook2Id = testPB2List[0].Id, UnitPrice = 5.0, UseStandardPrice = false, IsActive = true);
            insert testPBE;
           
           
            Opportunity oppObj = new Opportunity(Name='Test Opp',StageName='Closed Won - In-Kind',CloseDate=System.Today(),AccountId=testAccount.Id, type='Membership - New');
            insert oppObj;
           
            OpportunityLineItem testOPL = new OpportunityLineItem(OpportunityId = oppObj.Id, Quantity = 1.0, TotalPrice = 100, PricebookEntryId = testPBE.Id);
            insert testOPL;
           
            OpportunityLineItem testOPL1 = new OpportunityLineItem(OpportunityId = oppObj.Id, Quantity = 1.0, TotalPrice = 100, PricebookEntryId = testPBE.Id);
            insert testOPL1;
           
        
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
          
            Opportunity[] oppOpen =[Select Id,Amount from Opportunity Where (StageName='Open' or StageName='Membership - Renewal') and AccountId =:testAccount.Id];
            System.assertEquals(1, oppOpen.size());
          
            OpportunityLineItem[] oppLi =[Select Id,TotalPrice from OpportunityLineItem Where OpportunityId=:oppOpen[0].Id];
            System.assertEquals(2, oppLi.size());
            System.assertEquals(100, oppLi[0].TotalPrice);
            System.assertEquals(100, oppLi[1].TotalPrice);
           
            Opportunity[] oppRec = [Select Id from Opportunity];
            delete oppRec;
           
            Opportunity oppOb = new Opportunity(Name='Test Opp1',StageName='Open',CloseDate=System.Today(),AccountId=testAccount.Id);
            insert oppOb;
           
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
           
            Opportunity[] oppRec1 = [Select Id from Opportunity];
THIS IS LINE 52: delete oppRec1;
           
            Opportunity oppOb1 = new Opportunity(Name='Test Opp1',StageName='Open',CloseDate=System.Today(),AccountId=testAccount.Id,Type = 'Membership - New');
            insert oppOb1;
           
            testAccount.Generate_Renewal_Oppty__c = true;
            update testAccount;
           
            //delete oppOpen;
                      
        }
 
}


TEST RESULT DETAIL:

Class: generateRenewalOppty_TEST

Method Name: myTest

Pass/Fail: Fail

Error Message: System.LimitException: Too many DML rows: 10001

Stack Trace: Class.generateRenewalOppty_TEST.myTest: line 52, column 1