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

Difference between revisions of "Orion/Node/Developing"

< Orion‎ | Node
m (Orion/Node/Tests moved to Orion/Node/Developing: don't need a separate tests page yet-- put it under 'developing')
(Minification for speed and profit*)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Unit tests ==
+
This page explains how to develop the experimental Node.js-based Orion server. See [[Orion/Node/Getting started]] for an introduction.
 +
 
 +
== Running the tests ==
 
Our unit tests are written against the [http://visionmedia.github.com/mocha/ Mocha] test framework.
 
Our unit tests are written against the [http://visionmedia.github.com/mocha/ Mocha] test framework.
  
=== Running the tests ===
 
 
From the <code>org.eclipse.orion.client/modules/orionode</code> directory, just run the command:
 
From the <code>org.eclipse.orion.client/modules/orionode</code> directory, just run the command:
 
   npm test
 
   npm test
  
 
This will invoke Mocha and produce console output showing which tests passed and failed.
 
This will invoke Mocha and produce console output showing which tests passed and failed.
 +
[[Image:Orion-Node-Developing-testrun.png]]
 +
  
 
If you didn't install the Mocha package globally (or if you want to pass custom arguments to Mocha), run this instead:
 
If you didn't install the Mocha package globally (or if you want to pass custom arguments to Mocha), run this instead:
Line 19: Line 22:
 
#* [http://visionmedia.github.com/mocha/ Mocha reference]: the general structure of a test.
 
#* [http://visionmedia.github.com/mocha/ Mocha reference]: the general structure of a test.
 
#* [http://visionmedia.github.com/superagent/ Superagent reference]: how to write concise assertions for testing HTTP.
 
#* [http://visionmedia.github.com/superagent/ Superagent reference]: how to write concise assertions for testing HTTP.
# [[# Running the tests|Run the tests]].
+
# Run the tests (see instructions above).
 
#* You don't have to register your new tests with the framework; it will discover anything in the <code>test/</code> directory automatically.
 
#* You don't have to register your new tests with the framework; it will discover anything in the <code>test/</code> directory automatically.
  
 
Helper data or classes should go in <code>test/support/</code>.
 
Helper data or classes should go in <code>test/support/</code>.
  
[[Category:Orion|Node/Tests]]
+
=== Minification for speed and profit* ===
 +
The client code can be [http://en.wikipedia.org/wiki/Minification_%28programming%29 minified]. This greatly reduces load times when accessing the server. See [[Orion/Releng Builds]] for instructions.
 +
 
 +
* Profit not guaranteed
 +
 
 +
[[Category:Orion|Node]]
 +
[[Category:Orion/Node|Developing]]

Latest revision as of 11:27, 7 March 2014

This page explains how to develop the experimental Node.js-based Orion server. See Orion/Node/Getting started for an introduction.

Running the tests

Our unit tests are written against the Mocha test framework.

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. Orion-Node-Developing-testrun.png


If you didn't install the Mocha package globally (or if you want to pass custom arguments to Mocha), run this instead:

 ./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:

  1. Create a new file my_tests.js in the org.eclipse.orion.client/modules/orionode/test/ directory.
  2. Write your tests in the file. Here are two resources to help you get started:
  3. Run the tests (see instructions above).
    • You don't have to register your new tests with the framework; it will discover anything in the test/ directory automatically.

Helper data or classes should go in test/support/.

Minification for speed and profit*

The client code can be minified. This greatly reduces load times when accessing the server. See Orion/Releng Builds for instructions.

  • Profit not guaranteed

Back to the top