You need to sign in to do that
Don't have an account?
Writing a test class for this simple method
I am new to salesforce and given the documentation I am at a loss of where to start! If someone could write a test class for the following piece of code that would be most handy. I have simplified the method. I don't quite understand the 100% code coverage. I saw another post write something that didn't really make a whole bunch of sense.
public static string getJsonListOfAccounts () { String searchName = Apexpages.currentPage().getParameters().get('name'); String searchType = Apexpages.currentPage().getParameters().get('type'); List<Account> listOfAccounts = new List<Account>(); if (searchType == 'yes') { jsonListOfAccounts = [SELECT Id, Name, SummitElse from Account where example__c =: 'yes' AND Name like : '%'+ searchString +'%']; } else { jsonListOfAccounts = [SELECT Id, Name from Account where example__c =: 'no' AND Name like : '%'+ searchString +'%']; } return JSON.serializePretty(jsonListOfAccounts); }
you could start by following below code.
Hope this helps.
Ashish Kr.