Apex Test Results View

The Force.com IDE’s Apex Test Results view displays the results of your test runs. This view is useful for troubleshooting code, tuning performance, and checking resource usage.

All Apex test execution occurs on the server. Before testing your code, save any changes to the server.

Note

To execute Apex unit tests:
  1. Select Run | Run Configurations | Apex Test | New launch configuration (New launch configuration icon).
  2. Select the Test tab.
  3. Add tests to your run configuration.
    • To add a test class or test method, click one of the Search buttons. To select a method, first select the class that contains that method.
    • To create a run of test suites:
      1. Select Use suites.
      2. Select one or more test suites.
  4. Click Apply.
  5. To execute the selected test run configuration, click Run.
Run Configurations window: Test tab

To set log levels for an Apex test run, use your run configuration’s Project tab. Logging settings in your project’s properties apply only when you’re deploying code.

Run Configurations window: Project tab

After a test run, the Apex Test Runner view displays results. The left pane displays test results for each class and method in the test run. The right pane displays code coverage, the stack trace, system debug logs, and user debug logs. Make sure that your code has better coverage than the code in this sample org!

Apex Test Results view

To view code coverage highlighting, double-click a class name in the Apex Test Results pane’s Code Coverage list. Lines that aren’t covered by your unit tests are highlighted. Unlike the Developer Console, which color-codes both covered and uncovered lines, the Force.com IDE highlights only the lines of code that still need coverage.

Code coverage highlighting for a class with 75% coverage

To change the color for your uncovered code or to replace the highlighting with squiggly underlining, select Window | Preferences. Enter Annotations in the filter text box, then select Annotations | Apex Code Coverage. Make your desired changes, and then click Apply.

Annotations preferences for Apex code coverage