Skip to main content
Jump to: navigation, search

Difference between revisions of "Equinox/p2/Testing"

< Equinox‎ | p2
(Automated tests)
(Automated tests)
Line 13: Line 13:
 
Most tests subclass the common base class AbstractProvisioningTest. This class has a large number of utility methods for simplifying interaction with p2, and for p2-specific assertions. Here is a very simple test that illustrates some of the convenience methods on AbstractProvisioningTest:
 
Most tests subclass the common base class AbstractProvisioningTest. This class has a large number of utility methods for simplifying interaction with p2, and for p2-specific assertions. Here is a very simple test that illustrates some of the convenience methods on AbstractProvisioningTest:
  
IInstallableUnit toInstall= createIU("A_Simple_IU");
+
IInstallableUnit toInstall= createIU("TestIU");
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstall};
+
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstall};
createTestMetdataRepository(toInstallArray);
+
createTestMetdataRepository(toInstallArray);
IDirector director = createDirector();
+
IDirector director = createDirector();
IProfile satisfied = createProfile("Satisfied." + getName(), null, null);
+
IProfile profile= createProfile("TestProfile", null, null);
ProfileChangeRequest request = new ProfileChangeRequest(satisfied);
+
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(toInstallArray);
+
request.addInstallableUnits(toInstallArray);
IStatus result = director.provision(request, null, null);
+
IStatus result = director.provision(request, null, null);
assertProfileContains("1.1", satisfied, toInstallArray);
+
assertProfileContains("1.1", profile, toInstallArray);
  
 
Note that these convenience methods also help with test cleanup. For example, any profile created with the createProfile() method will be automatically removed in the test's tearDown method.
 
Note that these convenience methods also help with test cleanup. For example, any profile created with the createProfile() method will be automatically removed in the test's tearDown method.

Revision as of 21:23, 29 September 2008

This page collects information on working with and running the automated and manual tests for p2.

Automated tests

To run the automated tests, start by checking out org.eclipse.equinox.p2.releng from /cvsroot/rt/org.eclipse.equinox/p2. Then import one of the project sets in this project depending on whether you want to use the extssh (for committers) or pserver (for others) connection method. Select the appropriate project set file and click "Import Project Set" from the context menu.

The p2 tests all require Java 5 or later to run. The tests are all regularly run on Windows, Linux, and Mac, but should run on other platforms as well. Please enter bug reports for test failures on any os/ws/arch combination supported by Equinox.

Structurally all but the UI tests fall under the single AutomatedTests suite in org.eclipse.equinox.p2.tests. The UI tests have their own separate AutomatedTests entry point because they use the GUI test runner as opposed to the headless test runner. This means there are two suites to run to exercise all the tests. Note that the UI tests also exercise core code so it is valuable to run both suites even when changes are made in core areas.

With the exception of the End2EndTest, all of these tests are quite fast to run, so we should all be in the habit of running these tests before releasing any code changes. If you're on a slow connection you can either comment out the End2EndTest, or kill the test run when the last core test is started (this test always runs last).

Most tests subclass the common base class AbstractProvisioningTest. This class has a large number of utility methods for simplifying interaction with p2, and for p2-specific assertions. Here is a very simple test that illustrates some of the convenience methods on AbstractProvisioningTest:

IInstallableUnit toInstall= createIU("TestIU");
IInstallableUnit[] toInstallArray = new IInstallableUnit[] {toInstall};
createTestMetdataRepository(toInstallArray);
IDirector director = createDirector();
IProfile profile= createProfile("TestProfile", null, null);
ProfileChangeRequest request = new ProfileChangeRequest(profile);
request.addInstallableUnits(toInstallArray);
IStatus result = director.provision(request, null, null);
assertProfileContains("1.1", profile, toInstallArray);

Note that these convenience methods also help with test cleanup. For example, any profile created with the createProfile() method will be automatically removed in the test's tearDown method.

Framework admin tests

Due to the fact that frameworkadmin has no knowledge of or dependency on p2, its tests are stored in a separate project: org.eclipse.equinox.frameworkadmin.test. However, its main test suite is linked into the AutomatedTests class in org.eclipse.equinox.p2.tests, so no extra step is needed to run these tests.

Installer tests

Repository tests

We have a fairly good collection of *real* metadata repositories, artifact repositories, and legacy update site repositories in org.eclipse.equinox.p2.tests/testData{artifactRepo,metadataRepo,updatesite}. This makes it fairly easy to write tests involving various kinds of well-formed and invalid repositories. Feel free to add further reasonably sized repositories here for testing other code paths, failure cases, regression tests, etc. Typically we try to write tests against local repositories to ensure good test performance, but there are a small number of tests that access repositories on http://eclipse.org for testing issues that only arise on remote repositories.

Dropins reconciler tests

To run the reconciler tests, there is a one-time setup required because it requires a copy of the platform runtime binary. You need to do the following:

  1. Download the latest release of the Eclipse project platform runtime binary zip for your os/ws/arch.
  2. Use a system property to specify the location of this zip in the test launch configuration (-Dorg.eclipse.equinox.p2.reconciler.tests.platform.archive=<some_path>eclipse-platform-3.4-win32.zip).

The "all p2 tests" launch configuration in the p2.tests bundle has this property set, but you'll likely need to tweak the path of the zip for your machine.

Publisher tests

The publishers test make use of the EasyMock testing framework. You'll need to know a bit about EasyMock to understand and work with these tests.

Manual tests

The p2 team maintains a set of manual smoke test scenarios for exercising functionality difficult to capture in automated tests. See the manual test scripts for more details.

Back to the top