You need to sign in to do that
Don't have an account?

System.QueryException: List has no rows for assignment to SObject
Hi all,
Test class error on this line
OpportunityPipeline_Change__c pc = [select Stage_After__c from pportunityPipeline_Change__c where Opportunity__c = :O.Id];
I tried using list and limit.
Thanks
kumar
Test class error on this line
OpportunityPipeline_Change__c pc = [select Stage_After__c from pportunityPipeline_Change__c where Opportunity__c = :O.Id];
I tried using list and limit.
Thanks
kumar
Can you post the whole code as how you are doing it,I am assuming that you are not associating pportunityPipeline_Change__c record with correct Opportunity record.
@isTest
private class OpportunityPipelineChangeTest {
static testMethod void myUnitTest() {
//COMMENT: First, prepare Dummy Opportunity
Account a = new Account(Name='OpportunityPipelineChangeTest',Geography__c='TestGeography',Territory_Id__c='TestTerritory',
Territory_Overlay__c='TestTerritoryOverlay',Renewals_Team__c='TestRenewalsTeam',Renewals_Account_Manager__c='TestRenewalsAccountManager');
insert a;
Contact c = new Contact(AccountId=a.id,LastName='Test',Job_Function__c='TestJobFunction',Department__c='TestDepartment');
insert c;
Opportunity O = new Opportunity(Name='TestPipelineChange',AccountId=a.id,End_User__c=a.id,
Contact__c=c.id,CloseDate=System.today(),Type='New Customer',Order_Type__c='New',
Lead_Source_Category__c='Existing Customer',StageName='Create',Primary_Business_Driver__c='Test');
insert O;
//COMMENT: Inserting the record with should have caused trigger to fire which means you can move on to the verification steps
//COMMENT: Verify correct action using System asserts (these make sure your trigger did what it is supposed to)
//COMMENT: first, we locate the Pipeline Change record that has been added
OpportunityPipeline_Change__c pc = [select Stage_After__c from OpportunityPipeline_Change__c
where Opportunity__c = :O.Id];
//COMMENT: then we assert that the field we updated equals the field it was updated from
System.assert(pc.stage_after__c == 'Create');
}
}
Thanks
OpportunityPipeline_Change__c oPC = new OpportunityPipeline_Change__c (Opportunity__c = o.Id, Other Required Fields);
insert oPC;