You need to sign in to do that
Don't have an account?
sfdc007
Test class apex help needed
Hi,
I have a apex class for which i have a test class which covers 57% right now , i need help to cover certain methods which i am not able to cover
Kindly help me on this regard
Method need to cover
public boolean getteamFormStatus() {
boolean blStatus = false;
System.debug('TeamFormparaId:'+paraId);
gpsquoteobj = [select GPSTeamForm__r.Status__c,GPSTeamForm__r.Engagement_Script__c,GPSTeamForm__r.Engagement_Team__c,Quote_Status__c,Quote_Comments__c,LastModifiedBy.name,LastModifiedDate,Name,PremiSys_Quote_Id__c,GPSTeamForm__c,Quote_Version__c,CreatedDate,GPSTeamForm__r.Name from GPS_PremiSys_Quote__c
where id =:paraId order by CreatedDate desc];
if(gpsquoteobj.GPSTeamForm__r.Status__c == 'Won')
{
blStatus = true;
return blStatus;
}
return blStatus;
}
MY TEST CLASS :
When i write objinstance.methodname() dirctly i am getting list has no rows error
Kindly help me pls
Thanks in Advance
I have a apex class for which i have a test class which covers 57% right now , i need help to cover certain methods which i am not able to cover
Kindly help me on this regard
Method need to cover
public boolean getteamFormStatus() {
boolean blStatus = false;
System.debug('TeamFormparaId:'+paraId);
gpsquoteobj = [select GPSTeamForm__r.Status__c,GPSTeamForm__r.Engagement_Script__c,GPSTeamForm__r.Engagement_Team__c,Quote_Status__c,Quote_Comments__c,LastModifiedBy.name,LastModifiedDate,Name,PremiSys_Quote_Id__c,GPSTeamForm__c,Quote_Version__c,CreatedDate,GPSTeamForm__r.Name from GPS_PremiSys_Quote__c
where id =:paraId order by CreatedDate desc];
if(gpsquoteobj.GPSTeamForm__r.Status__c == 'Won')
{
blStatus = true;
return blStatus;
}
return blStatus;
}
MY TEST CLASS :
@isTest(seeallData = true) public class GpsPremiSysQuoteRLController_test { static testmethod void GpsPremiSysQuoteRLTestMethod(){ string strUsr; User usr = GPSTestUtilities.createStandardUser(strUsr); System.runAs(usr){ Account acct = GPSTestUtilities.createTestAccount(); Pricebook2 pb = GPSTestUtilities.getTestPriceBook(); product2 pr = GPSTestUtilities.createproduct(); test.startTest(); Product_Designator__c pd = GPSTestUtilities.createprodDesignator(); Opportunity op = GPSTestUtilities.createTestOpportunity(acct.Id); OpportunityLineItem opline = GPSTestUtilities.createTestOpportunityLineItem(op.Id); //list<OpportunityLineItem>lstopplt = [select ]; GPS_PRx__c prx = GPSTestUtilities.createGPSPRX(pd.Id); test.stopTest(); system.debug('OpptyID=>'+op.Id); Engagement_Script__c EP = GPSTestUtilities.createEngagementScript(acct.Id,op.Id); system.debug('EP=>'+EP); Team_Form__c TF = GPSTestUtilities.createTeamForm(EP.Id); GPS_TF_Product_Line_Item__c prlitem = GPSTestUtilities.createGPSLineitms(prx.Id, EP.Id, TF.Id); GPS_PremiSys_Quote__c Quote = GPSTestUtilities.createPremisysQuote(EP.Id, TF.Id); //set up GPS Premisys Quote GPS_PremiSys_Quote__c sdquote = new GPS_PremiSys_Quote__c(); sdquote.Quote_Status__c='New'; sdquote.GPSTeamForm__c =TF.Id; sdquote.Engagement_Script_Id__c=EP.Id; sdquote.Quote_Comments__c='Test'; insert sdquote; ApexPages.currentPage().getParameters().put('id', TF.Id); // Apexpages.StandardController sc = new Apexpages.StandardController (TF); GpsPremiSysQuoteRLController objquoteRLcon = new GpsPremiSysQuoteRLController(); // objquoteRLcon.getGpsPremiSysQuoteList(); objquoteRLcon.Custsave(); } } static testmethod void GpsPremiSysQuoteRLTestMethodNoES(){ string strUsr; User usr = GPSTestUtilities.createStandardUser(strUsr); System.runAs(usr){ Account acct = GPSTestUtilities.createTestAccount(); Pricebook2 pb = GPSTestUtilities.getTestPriceBook(); product2 pr = GPSTestUtilities.createproduct(); Product_Designator__c pd = GPSTestUtilities.createprodDesignator(); Opportunity op = GPSTestUtilities.createTestOpportunity(acct.Id); test.startTest(); OpportunityLineItem opline = GPSTestUtilities.createTestOpportunityLineItem(op.Id); //list<OpportunityLineItem>lstopplt = [select ]; GPS_PRx__c prx = GPSTestUtilities.createGPSPRX(pd.Id); system.debug('OpptyID=>'+op.Id); Engagement_Script__c EP = GPSTestUtilities.createEngagementScript(acct.Id,op.Id); system.debug('EP=>'+EP); Team_Form__c TF = GPSTestUtilities.createTeamForm(EP.Id); GPS_TF_Product_Line_Item__c prlitem = GPSTestUtilities.createGPSLineitms(prx.Id, EP.Id, TF.Id); //GPS_PremiSys_Quote__c Quote = GPSTestUtilities.createPremisysQuote(EP.Id, TF.Id); test.stopTest(); ApexPages.currentPage().getParameters().put('id', TF.Id); //Apexpages.StandardController sc = new Apexpages.StandardController (TF); GpsPremiSysQuoteRLController objquoteRLcon = new GpsPremiSysQuoteRLController(); // objquoteRLcon.getGpsPremiSysQuoteList(); objquoteRLcon.getteamFormStatus =true; } } }
When i write objinstance.methodname() dirctly i am getting list has no rows error
Kindly help me pls
Thanks in Advance
All Answers
I think, you will be fine if you change line no. 68 (objquoteRLcon.getteamFormStatus =true;) to system.debug(objquoteRLcon.getteamFormStatus());
suggestion :- remove @isTest(seeallData = true) anotation.
Thanks!
System.QueryException: List has no rows for assignment to SObject
public boolean getteamFormStatus() {
boolean blStatus = false;
System.debug('TeamFormparaId:'+paraId);
gpsquoteobj = [select GPSTeamForm__r.Status__c,GPSTeamForm__r.Engagement_Script__c,GPSTeamForm__r.Engagement_Team__c,Quote_Status__c,Quote_Comments__c,LastModifiedBy.name,LastModifiedDate,Name,PremiSys_Quote_Id__c,GPSTeamForm__c,Quote_Version__c,CreatedDate,GPSTeamForm__r.Name from GPS_PremiSys_Quote__c
where id =:paraId order by CreatedDate desc];
if(gpsquoteobj.GPSTeamForm__r.Status__c == 'Won')
{
blStatus = true;
return blStatus;
}
return blStatus;
}
i need help for the below condition too
kindly help me how to cover the above condition also pls
http://salesforce.stackexchange.com/questions/38753/apex-test-user-creation
User usr = GPSTestUtilities.createStandardUser(strUsr);