Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Eclipse/Testing

< Eclipse
Revision as of 10:34, 8 April 2009 by John arthorne.ca.ibm.com (Talk | contribs) (Profiling performance tests)

The Eclipse Platform is tested during every build by an extensive suite of automated tests. These tests are written using the JUnit test framework. This page contains links to information about how to run and create automated tests for the platform.

Correctness tests

The majority of automated tests are testing for program correctness. A test failure on these tests implies that program behaviour is not as expected by the tests. These tests are run every build on Windows, Linux, and Mac OSX.

  • See this page for information about running JUnit4 tests within the Automated Testing Framework.

Running tests from within Eclipse

Correctness tests can be run manually from within the Eclipse IDE using a "JUnit Plug-in Test" launch configuration:

  1. Check out the test plugin containing the tests you want to run, along with any prerequisite plug-ins. Here are some plug-ins you will likely need:
    • org.junit - The JUnit test framework
    • org.eclipse.test - The basic infrastructure for running Eclipse tests
    • org.eclipse.core.tests.harness - Various utility pieces used by many tests
    • org.eclipse.core.tests.runtime - Tests for the runtime component
    • org.eclipse.core.tests.resources - Tests for the resources component
    • org.eclipse.ui.tests.harness - Various utility pieces used by UI tests
    • org.eclipse.ui.tests - Tests for the Eclipse UI
  2. In the Navigator or Package Explorer, select the test or test suite you want to run. Each test package typically contains a TestSuite class that contains all the tests in that package. Suites from multiple packages are then aggregated into higher level suites. Here are some useful suites to know about:
    • org.eclipse.ui.tests.UiTestSuite - runs all UI tests
    • org.eclipse.core.tests.runtime.AutomatedTests - runs all runtime tests
    • org.eclipse.core.tests.resources.AutomatedTests - runs all resource tests
  3. Select Run > Run...
  4. Choose the "JUnit Plug-in Test" category, and click the button to create a new test
  5. On the "Main" tab, select the appropriate application for that test. Here are some important applications to know about:
    • [No Application] - Headless Mode - for running headless core (runtime, osgi, resource) tests
    • org.eclipse.ui.ide.workbench - for running UI tests
  6. Click Run.

Using EasyMock

In the Eclipse Galileo release the utility EasyMock was added to the platform test framework. EasyMock is used to create fake implementations of objects in order to test units of functionality in isolation from other objects. See the EasyMock documentation for more details.

To use EasyMock in your tests, simply load the org.easymock bundle from the Orbit repository. There is a convenience easymock.psf project set file in the org.eclipse.test bundle to facilitate loading of this bundle.

Note that EasyMock requires Java 5 or greater. At this time, we run tests on Java 1.4.2 and Java 5. This means you need to add the following to the Ant target for your tests (contact releng for details):

<target name="YourTestTarget" depends="setJVMProperties">
<property name="jvm" value="${J2SE-5.0}" />
<condition property="skip.test">
<not>
  <isset property="J2SE-5.0" />
</not>
</condition>
... remaining target definition as usual

Session tests

Session Tests in Eclipse are tests that require that a new Eclipse session be launched for every test case run. Thus, they have additional requirements regarding controling the environment test cases are run (VM, set of plug-ins available, configuration, instance location, command line parameters) and how results are communicated back to the test runner.

Performance tests

See the Performance Tests How-to

Profiling performance tests

It can be very useful to capture profiling data for performance tests, to help track down where the time is going. To ensure you are profiling exactly the same code paths that are running in the automated performance tests, you can attach a headless profiler to the performance tests within the test suite. Here are steps to attach a headless YourKit agent to a performance test. The resulting snapshots can later be opened for analysis from the YourKit client:

  1. Download the tests for the build you are interested in (available from same download page as the build itself).
  2. Unzip the test framework, and follow the instructions in the readme.html to configure your tests
  3. Create a properties file (let's say profile.properties) with the following contents:
 extraVMargs=-agentlib:yjpagent=sampling,onexit=snapshot
  1. 4 Invoke the performance test and specify the properties file location:
 runtests "-Dtest.target=performance" -properties profile.properties <yourtarget>

Back to Eclipse Project home

Back to the top