You need to sign in to do that
Don't have an account?
kavya g 3
Error: Method must define a body
Hii Floks
I have written a simple test class and getting this error "Method must define a body" @line 4
code:
@istest
public class testcontactsearch
{
@istest public static void testsearchForContacts();
{
contactsearch CS= new contactsearch(firstname='kavya');
system.assertEquals('kavya', c.firstname);
}
}
Thanx in Advance
I have written a simple test class and getting this error "Method must define a body" @line 4
code:
@istest
public class testcontactsearch
{
@istest public static void testsearchForContacts();
{
contactsearch CS= new contactsearch(firstname='kavya');
system.assertEquals('kavya', c.firstname);
}
}
Thanx in Advance
Thanks
I hop it helps you :)
All Answers
Thanks
@istest
public class testcontactsearch
{
@istest public static testMethod void testsearchForContacts(){
contactsearch CS= new contactsearch(firstname='kavya');
system.assertEquals('kavya', c.firstname);
}
}
Thanks
testmethod (or) @istest
we can use any one of these rite.
yup, i removed ; @line 4 but i ended with ''Variable does not exist: c.firstname'' error..
Thank you
public class testcontactsearch
{
@istest public static testMethod void testsearchForContacts(){
contact c = new contact(firstname='kavya');
system.assertEquals('kavya', c.firstname);
}
}
Thanks Mark it best answer if it helps you :)
I found new error "duplicate value found: <unknown> duplicates value on record with id: <unknown>"
Thanx for ur support Piyush
public class ContactSearch
{
public static void searchForContacts()
{
list<Contact> c=[select id,firstname from contact where firstname='kavya' limit 1];
system.debug(+c);
}
}
Testclass: (Modified)
@istest
public class testcontactsearch
{
@istest public static void testsearchForContacts()
{
contact c= new contact(firstname='kavya');
cs = c.searchForContacts();
system.assertEquals('kavya', cs.firstname);
}
}
Error: Variable does not exist: cs
now your class is 100% cover :)
error
"duplicate value found: <unknown> duplicates value on record with id: <unknown>"
Thanks
I hop it helps you :)