You need to sign in to do that
Don't have an account?
Saru Vadlamudi
Test class-Soql Code coverage for custom controller
i have test class for vf controller where as soql which is not not covering in code coverage even after inserting one test opp record.Please suggest me that how to get cover this soql.Here oppId is currentpage parameter.
In debug logs opppDeatils list value is coming as 0 but test opp record is inserted in test class.
List<Opportunity> oppDetails =[Select Name
From Opportunity
Where Id =:ApexPages.currentPage().getParameters().get('oppID')];
In debug logs opppDeatils list value is coming as 0 but test opp record is inserted in test class.
List<Opportunity> oppDetails =[Select Name
From Opportunity
Where Id =:ApexPages.currentPage().getParameters().get('oppID')];
All Answers
I would use system.debug right before the query to establish that this
is working properly. If you are absolutely sure that the opportunity is being inserted into the database (within the scope of this current test method) then that really is the only bit that can be causing the SOQL query to return no results.
http://amitsalesforce.blogspot.in/2015/06/best-practice-for-test-classes-sample.html
Please try below test class. I hope that will help you
ApexPages.currentPage().getParameters().put('oppID',Opp.Id);
I have if-else condition and able to cover only one scenario either positive and negative.
suggest me that how to cover the negative scenarios in test class.
I have created two diffrent methods for postive and negative but not working as expected and only negative scenario is excuting.
Please let me know what are can be the possibilities for this failues.
Sorry i have done silly mistake while passing the data for positive scenario.