function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike Reynolds 6Mike Reynolds 6 

Test method problems

Hey - I'm new (as everyone on here says) and i'm being thrown by an error message. Here is my test code:
@isTest
public class emailTriggerTestClass {
    static testMethod void isIncomingEmailTest() {
        case newCase = new Case();
        insert newCase;
        emailMessage newEmail = new emailMessage();
            newEmail.FromAddress = 'Email@No.com';
            newEmail.ToAddress = 'Feedback@no.com';
            newEmail.CcAddress = 'ccAddress@verify.com';
            newEmail.FromName = 'Someones Name';
            newEmail.Incoming = True;
            newEmail.ParentId=newCase.id;
        test.startTest();
            insert newEmail;
        test.stopTest();
           newCase=[select Id, Email_To_Address__c,From_Address__c,Email_CC_Address__c,Email_From_Name__c from case where id =:newEmail.ParentId];
    System.assertEquals ('email@no.com', newCase.From_Address__c);
    System.assertEquals ('Feedback@no.com', newCase.Email_To_Address__c);
    System.assertEquals ('ccAddress@verify.com', newCase.Email_CC_Address__c);
    System.assertEquals ('Someones Name', newCase.Email_From_Name__c);
    }
}
I'm getting the following error when I try to run my test:
"No tests to run. Add test methods to your test class."

This makes no sense to me. Any ideas?

Thanks - Mike



 
Best Answer chosen by Mike Reynolds 6
Mike Reynolds 6Mike Reynolds 6
I've been fiddeling with it and I just saved it back to it's original form that is listed above and it worked. No error. It was probably just a bug. Thanks everyone for the help!

All Answers

Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hello Mike,

I've test your class here and it's working fine! From where you are executing that test class? Developer Console? Setup? Eclipse?
Make sure your class is saved with the latest code. Setup -> Apex Classes -> Your test Class

Hope to have helped!

Regards.

Don't forget to mark your thread as 'SOLVED' with the answer that best helps you.
 
Mike Reynolds 6Mike Reynolds 6
I use the developer console. It's saved and I don't have any errors. At least none that I can find. 

-Mike
Zuinglio Lopes Ribeiro JúniorZuinglio Lopes Ribeiro Júnior
Hi Mike,

Can you send a print of it? Did you checked your class in the Setup? Have you tried to close and open the console again? Are you using the top right button Run Test?

Regards
Pavit SiddhuPavit Siddhu
Hello , i think u create an instance of your class, that's u want to unittest.
like if your class name is emailTrigger then
emailTrigger et = new emailTrigger();
Mike Reynolds 6Mike Reynolds 6
I've been fiddeling with it and I just saved it back to it's original form that is listed above and it worked. No error. It was probably just a bug. Thanks everyone for the help!
This was selected as the best answer
Raj_SinhaRaj_Sinha

I was also facing the same issue, 

After writing your code in developer console, you must save your code (ctrl+s) then you can run your command which might fix this issue.