There are multiple ways of running unit tests for APEX in Salesforce.
1) From Eclipse
Setup Eclipse on your computer. Right-click on any class that has tests in it and select. Force.com | Run Tests
2) From the Salesforce in a Browser
Log into Salesforce, Click on Your Name | Setup
In the App Setup section click on Develop | Apex Classes
Find your class and open it, then click on the Run Test button.
3) Using the Salesforce API
You can run a test of one class or multiple classes.
You are basically repeating what can be done in Eclipse, but you do have the choice to send multiple test classes at once.
The API does not give you a chance to retrieve the underlying debug code generated directly from this call though, so you will have to login directly to Salesforce to get this.
This can be developed using many languages including Java, C# and VB.NET.
I developed a VB.NET app that ran multiple tests at one point because Eclipse was not showing me the code coverage results correctly for certain projects.
4) Using the Developer Console
Log into Salesforce
Setup a Debug Log so you can review the output of your tests
In the Administration Setup section click on Monitoring | Debug Logs, Click New in the Monitored Users section and select yourself
Click on Your Name | Developer Console (You need to have the ‘Author APEX’ system permission to access the Developer Console)
Click on the Repository tab and open up the test class
Click on the Tests tab – Click on the ‘Run Test’ button just to the top and right of your class
After the test has run you can see the results in the Tests tab. To see your debug log flip back to Salesforce and hit the reset link by your name in the ‘Debug Logs’ window. This will refresh the page to show your debug log and also reset your number of available debug logs to 20.
The reason I am liking #4 more than the others is because of speed. It can take a very long time for Eclipse to find the debug log and then download it to my computer. Running the test using the Developer Console is very easy and very fast. The debug log is created, but I do not need to see the debug log every time. If I need the debug log then I can simply flip over to the Debug Logs window and view it. Another nice benefit with viewing the debug log in the browser is that I can use the browser’s search features to find the lines I am looking for. I do not need to copy/paste the debug lines into Notepad from Eclipse in order to find my lines.
Another hint to make tests run faster is to set the ‘Log Filters’ so that less data will show in the logs. Go to your Apex class that you are testing under App Setup | Develop | Apex Classes. Click on the Log Filters tab and check the ‘Override Log Filters’ checkbox. Now the ‘Level’ checkbox can be set to something like ‘INFO’ so there will be much less written to the debug logs. You will need to write your System.Debug calls with the ‘INFO’ parameter so that the line will appear in your debug logs. On extremely long running processes I have even set the Level to be ‘Error’ so that almost nothing is saved to the debug log. This can be done for triggers as well as classes.
I hope this has given you a simple way to be more productive each day. What is one of your favorite productivity tips?