You need to sign in to do that
Don't have an account?
Rodolfo Calvo
Cannot call test methods in non-test context
Hello team,
I have this code:
All my app is in @isTest
It shows an error:
What am I doing wrong?
I have this code:
public static testMethod PageReference search() { try { //runSearch(); results = performSearch(searchString); } catch(Exception e) { //showMessage = true; //message = 'An error has ocurred on public static testmethod PageReference search()'; } return null; } public static List<Account> performSearch(String sString) { searchString = sString; //String will make a callback of contacs String soql = 'select id, name, type, description, website, phone from Account'; if(searchString != '' && searchString != null) soql = soql + ' where name LIKE \'%' + searchString +'%\''; soql = soql + ' limit 25'; System.debug(soql); return database.query(soql); }
All my app is in @isTest
It shows an error:
Cannot call test methods in non-test context Error is in expression '{!search}' in component <apex:commandButton> in page lca: External entry point
What am I doing wrong?
I did this:
All Answers
In general test methods are void therefor don't return anything. So if it's test method change PageReference to void and remove return statement.
if it is a normal class remove the testMethod keyword.
Regards
Adrian
I did this: