Orion/JS Unit Test

From Eclipsepedia

Jump to: navigation, search

Contents

Writing Javascript unit test cases

We are using JS Test Driver for the Javascript unit test. Here are steps to write your own test cases.

  • Test cases can be declared in .js files under your project. We recommend you create a folder under your project like this:

Orion-Jstest-Folder.png

  • A .js file can declare as many test cases as you want but we recommend you declare one test case per file.
  • The test case declaration is as below. You will declare all the tests as functions .For more details refer to here.
MyTestCase = TestCase("MyTestCase");
MyTestCase.prototype.testA = function(){};
  • There is a list of default assertions of JsTestDriver. Refer to here to use them in your testcases.

Test configuration

In order for JsTestDriver to run the test cases , you should:

  • Create a file called jsTestDriver.conf directly under your project root folder.
  • The content of the conf file is something like below. Refer to here for details.
server: http://localhost:8082
load:
- web/js/*.js   
- web/js-tests/*.js


Running test cases

There are 2 options currently and will be one more in the future , to run the test cases you've written.

Running from daily build automatically

  • Once you've done the steps on test case and configuraion, Orion Build will do a search for all jsTestDriver.conf files in all client projects and run js unit test on each .conf file.
  • The result will be reported as an HTML table on the daily build page as below. Refer to here as a sample.

Orion-jstest-buildresult.png


Running locally from Eclipse plugin

Running from Orion (future , under development)