• PamelaM
  • NEWBIE
  • 0 Points
  • Member since 2013

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

I have created a new app for my org, with new record types, page layouts, etc and deployed it between sandboxes (dev to full) to test the additions. This worked fine but now I'm trying to deploy it in my production org and the change set has failed the validation test.

Basically my problem is I'm not a developer and all the code in our org was written by a consultant before I joinedthe company so I don't want to change things in production when I'm not sure about them. Therefore I would appreciate any help that could be offered!

The new record type won't be using the funnel camp tracker so I'm not sure if that is part of the issue. Would it be possible to add something into the trigger to exclude the new record type I'm trying to deploy? 

 

 

Change set deployment error:

TestClass.testOpportunityTrigger() Class 49 1

Failure Message: "System.AssertException: Assertion Failed: Expected: 3, Actual: 0", Failure Stack Trace: "Class.TestClass.testOpportunityTrigger: line 49, column 1"

 

@isTest
private class TestClass {

    //Test Opportunity Trigger
    static testMethod void testOpportunityTrigger() {
        
        //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        
        test.startTest();
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty02', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty03', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        
        insert(testListOpty);
                
        //* Check Data, 3 opty therefore we should have 3 funnel trackers.
        system.assertEquals(3, [select Id from Funnel_Camp_Tracker__c where Opportunity__r.Account.Id = :testAccount.Id].size());
        
        test.stopTest();
    }
    
    static testMethod void testGamePlanController(){
      
      //* Create Test Data
      //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        Contact testContact = new Contact(FirstName = 'Bruce', LastName = 'Wayne', Phone = '123', Email = 'batman@batcave.com', MobilePhone = '321');
        insert(testContact);
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        insert(testListOpty);
        
        list<OpportunityContactRole> TestlistOCR = new list<OpportunityContactRole>();
        for(Integer i=0;i<5;i++){
          TestlistOCR.add(new OpportunityContactRole(Role = 'testRole' + i, OpportunityId = testListOpty[0].Id, ContactId = testContact.Id));
        }
        
        insert (TestlistOCR);
        
      test.startTest();
      
      pageReference p = Page.GenerateGamePlan;
      p.getParameters().put('id', testListOpty[0].Id);
        test.setCurrentPage( p );
        GamePlanController GPC = new GamePlanController();
        GPC.oOpty = testListOpty[0];
              
      test.stopTest();
      
    
    }
}

 

I have created a new app for my org, with new record types, page layouts, etc and deployed it between sandboxes (dev to full) to test the additions. This worked fine but now I'm trying to deploy it in my production org and the change set has failed the validation test.

Basically my problem is I'm not a developer and all the code in our org was written by a consultant before I joinedthe company so I don't want to change things in production when I'm not sure about them. Therefore I would appreciate any help that could be offered!

The new record type won't be using the funnel camp tracker so I'm not sure if that is part of the issue. Would it be possible to add something into the trigger to exclude the new record type I'm trying to deploy? 

 

 

Change set deployment error:

TestClass.testOpportunityTrigger() Class 49 1

Failure Message: "System.AssertException: Assertion Failed: Expected: 3, Actual: 0", Failure Stack Trace: "Class.TestClass.testOpportunityTrigger: line 49, column 1"

 

@isTest
private class TestClass {

    //Test Opportunity Trigger
    static testMethod void testOpportunityTrigger() {
        
        //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        
        test.startTest();
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty02', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty03', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        
        insert(testListOpty);
                
        //* Check Data, 3 opty therefore we should have 3 funnel trackers.
        system.assertEquals(3, [select Id from Funnel_Camp_Tracker__c where Opportunity__r.Account.Id = :testAccount.Id].size());
        
        test.stopTest();
    }
    
    static testMethod void testGamePlanController(){
      
      //* Create Test Data
      //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        Contact testContact = new Contact(FirstName = 'Bruce', LastName = 'Wayne', Phone = '123', Email = 'batman@batcave.com', MobilePhone = '321');
        insert(testContact);
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        insert(testListOpty);
        
        list<OpportunityContactRole> TestlistOCR = new list<OpportunityContactRole>();
        for(Integer i=0;i<5;i++){
          TestlistOCR.add(new OpportunityContactRole(Role = 'testRole' + i, OpportunityId = testListOpty[0].Id, ContactId = testContact.Id));
        }
        
        insert (TestlistOCR);
        
      test.startTest();
      
      pageReference p = Page.GenerateGamePlan;
      p.getParameters().put('id', testListOpty[0].Id);
        test.setCurrentPage( p );
        GamePlanController GPC = new GamePlanController();
        GPC.oOpty = testListOpty[0];
              
      test.stopTest();
      
    
    }
}