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

strange issues on test classes

1. created a test class and inserted an opportunity with stage value as 'started';

2. once the insertion was done changed the stage value to 'in progress' and used update statement to update the same.

3. its entering in to the before trigger event but not firing the class method based on th below condition.


test class:

    opprtunity opp = new opportunity(stagename = 'started', name = 'test name');

insert opp;

opp.stagename='in progress';

update opp;


if([0].stagename == 'in progress' && trigger.old[0].stagename == 'started')// this is covering.

     hadnler.getoppor([0]);///This is not executing in my scenario



plez help me out in this


Did you chek what the[0].stagename and trigger.old[0].stagename values are ?


It may help if you post your full trigger & test code.




this is my code in opportunity trigger

OpportunityTriggerHandler_AC.beforeUpdateRecursiveFlag = true;
//Start Code change By Kiran
if([0].RecordTypeid == Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get(RecordTypeConstants_AC.OPTY_ALLIANCE_AGREEMENT_RT).getRecordTypeId()){
if([0].stagename == '30 - Solution Presentation' && trigger.old[0].StageName == '22 - Proposal Development')


test class code:

Account objAct = new Account();
objAct.RecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get(RecordTypeConstants_AC.ACCOUNT_BUSINESS_ACCOUNT_RT).getRecordTypeId();
objAct.Name = 'test acct';
objAct.Account_Owner_Manager__c = userinfo.getUserId();
//objAct.CCM__c = userinfo.getuserid();
//objAct.Proposal_Manager__c = userinfo.getuserid();
//objAct.Sponsor__c = userinfo.getuserid();
insert objAct;
Opportunity objOpp = new Opportunity();
objOpp.AccountId =;
objOpp.StageName = '22 - Proposal Development';
objOpp.RecordTypeId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get(RecordTypeConstants_AC.OPTY_ALLIANCE_AGREEMENT_RT).getRecordTypeId();
objOpp.Name = 'test opp';
objopp.Class_Type__c = 'Academic Partnership - AMOU';
objOpp.CloseDate =;
objOpp.Type_of_Agreement__c = 'AMOU';
insert objOpp;

objOpp.stagename = '30 - Solution Presentation';

update objOpp;