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.
Orion/Running the tests
Contents
Client tests
Running a test
- Tests are located under the
js-test
folders. - A test is defined by an HTML file, typically named
test.html
. - To run a test, load its
test.html
file in your browser. (Example:http://[your_orion_server]/js-tests/serviceRegistry/test.html
)- Test output is printed to the JavaScript console.
JVM Server tests
Setting up
- Set up your Eclipse IDE as explained in Orion/Getting the source.
- Make sure you have imported the test projects into your workspace, and they're open:
- org.eclipse.orion.server.tests
- org.eclipse.orion.server.tests.feature
- The test projects have additional dependencies over the rest of the Orion source code. The next 3 steps explain how to satisfy them.
- Add the plugins from your Eclipse SDK to your target platform:
- Now we will checkout the remaining test dependencies from CVS. Download this file:
File:OrionServerTestDepdendencies.psf. - In your Eclipse IDE, go to File -> Import -> Team -> Team Project Set, select OrionServerTestDependencies.psf, and click Finish.
- At this point you should have no Java compilation errors. You can now run the tests.
Manually checking out the dependent projects
If the previous section fails for some reason, here's the list of projects from the .psf file. You can check them out manually if need be.
Projects from the Eclipse Platform CVS repository (/cvsroot/eclipse
):
- org.eclipse.core.runtime.compatibility
- org.eclipse.core.runtime.compatibility.auth
- org.eclipse.core.tests.harness
- org.eclipse.core.tests.resources
- org.eclipse.test.performance
- org.eclipse.test.performance.data
- org.eclipse.test.performance.win32
Projects from the Orbit CVS repository (/cvsroot/tools
):
- javax.mail.glassfish (Branch v1_4_1)
- org.antlr.runtime (Branch v3_2_0)
- org.hamcrest.core (Branch v1_1)
- org.junit (Branch v3_8_2)
- org.junit4 (Branch v4_8_2)
Running
- Go to the org.eclipse.orion.server.tests project.
- Open the launchConfigurations folder, right-click All Server Tests.launch and choose Run As > All Server Tests.
- The JUnit view will open and display the test results.
To run just a subset of the tests, edit the launch configuration (Run > Run Configurations).
Node.js Server Tests
Our Node server unit tests are written against the Mocha test framework.
Running the tests
From the org.eclipse.orion.client/modules/orionode
directory, just run the command:
npm test
This will invoke Mocha and produce console output showing which tests passed and failed.
If you want to pass custom arguments to Mocha, you'll need to invoke it explicitly like this:
./node_modules/mocha/bin/mocha [debug] [options] [files]
To make this easier, you can install Mocha as a global npm package (npm install mocha -g
), and then invoke it as simply mocha
from a command shell.
Writing more tests
When you're prototyping a new feature, writing unit tests for it is always a good idea. Here's how to write a test:
- Create a new file
my_tests.js
in theorg.eclipse.orion.client/modules/orionode/test/
directory. - Write your tests in the file. Here are two resources to help you get started:
- Mocha reference: the general structure of a test.
- Superagent reference: how to write concise assertions for testing HTTP.
- Run the tests.
- You don't have to register your new tests with the framework; it will discover anything in the
test/
directory automatically.
- You don't have to register your new tests with the framework; it will discover anything in the
Helper data or classes should go in test/support/
.