You need to sign in to do that
Don't have an account?
Soundar
Test Class Coverage With Explanation
Dear friends,
I am new to the development , could you please cover the test class for following code with explaination.
Code
---------------------------------------------------------------------------------
public with sharing class AccountDealOpportunity {
public AccountDealOpportunity(ApexPages.StandardController controller) {
lstOpp = new List<Opportunity__c>();
AccId = ApexPages.currentPage().getParameters().get('id');
Account iAcc = [SELECT id, Recordtype.Name, Name FROM Account WHERE Id =: AccId];
String Query = 'SELECT id, Name, Originator__c, Investor__c, Interested_Products__c, Asset_Class__c, Investor_Category__c,'+
+'Amount__c,Valid_Till__c,RecordType.Name FROM Opportunity__c where ';
if(iAcc.RecordType.Name == 'Investor')
{
query = query + 'Investor__c =: AccId';
}
else if(iAcc.RecordType.Name == 'Originator')
{
query = query + 'Originator__c =: AccId';
}
lstOpp = Database.query(query);
}
public List<Opportunity__c> lstOpp {get;set;}
Public Boolean isShowOpp {get;set;}
String AccId;
public AccountDealOpportunity()
{
}
public pageReference CreateDeal()
{
PageReference DealPage = new PageReference('/apex/CreateDeals?id=' + AccId);
DealPage.setRedirect(true);
return DealPage;
}
public pageReference OpportunitytoDeal()
{
return Null;
}
}
------------------------------------------------------------------------
Thanks In Advance ....
Regards,
Soundar Raj
I am new to the development , could you please cover the test class for following code with explaination.
Code
---------------------------------------------------------------------------------
public with sharing class AccountDealOpportunity {
public AccountDealOpportunity(ApexPages.StandardController controller) {
lstOpp = new List<Opportunity__c>();
AccId = ApexPages.currentPage().getParameters().get('id');
Account iAcc = [SELECT id, Recordtype.Name, Name FROM Account WHERE Id =: AccId];
String Query = 'SELECT id, Name, Originator__c, Investor__c, Interested_Products__c, Asset_Class__c, Investor_Category__c,'+
+'Amount__c,Valid_Till__c,RecordType.Name FROM Opportunity__c where ';
if(iAcc.RecordType.Name == 'Investor')
{
query = query + 'Investor__c =: AccId';
}
else if(iAcc.RecordType.Name == 'Originator')
{
query = query + 'Originator__c =: AccId';
}
lstOpp = Database.query(query);
}
public List<Opportunity__c> lstOpp {get;set;}
Public Boolean isShowOpp {get;set;}
String AccId;
public AccountDealOpportunity()
{
}
public pageReference CreateDeal()
{
PageReference DealPage = new PageReference('/apex/CreateDeals?id=' + AccId);
DealPage.setRedirect(true);
return DealPage;
}
public pageReference OpportunitytoDeal()
{
return Null;
}
}
------------------------------------------------------------------------
Thanks In Advance ....
Regards,
Soundar Raj
I hope it will help you.
Apex Class: Test Class:
Thanks,
Ankur Saini
http://mirketa.com
All Answers
I hope it will help you.
Apex Class: Test Class:
Thanks,
Ankur Saini
http://mirketa.com
Really Thanks it's working fine.
Could You please give me your mail id.
Regards,
Soundar Raj.
Now It's Covering 94% as well. But onle line is not covering. Can you please advise why it's not covering.
public with sharing class AccountDealOpportunity {
public AccountDealOpportunity(ApexPages.StandardController controller) {
lstOpp = new List<Opportunity__c>();
AccId = ApexPages.currentPage().getParameters().get('id');
Account iAcc = [SELECT id, Recordtype.Name, Name FROM Account WHERE Id =: AccId];
String Query = 'SELECT id, Name, Originator__c, Investor__c, Interested_Products__c, Asset_Class__c, Investor_Category__c,'+
+'Amount__c,Valid_Till__c,RecordType.Name FROM Opportunity__c where ';
if(iAcc.RecordType.Name == 'Investor')
{
query = query + 'Investor__c =: AccId';
}
else if(iAcc.RecordType.Name == 'Originator')
{
query = query + 'Originator__c =: AccId';
}
lstOpp = Database.query(query);
}
public List<Opportunity__c> lstOpp {get;set;}
Public Boolean isShowOpp {get;set;} // This Line Is Not Covering....
String AccId;
public AccountDealOpportunity()
{
}
public pageReference CreateDeal()
{
PageReference DealPage = new PageReference('/apex/CreateDeals?id=' + AccId);
DealPage.setRedirect(true);
return DealPage;
}
public pageReference OpportunitytoDeal()
{
return Null;
}
}
Regards,
Soundar Raj.