Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Testing Guidelines

Manuel de la Peña edited this page Feb 23, 2015 · 7 revisions

No single commit should go to AlloyUI source tree without tests. Exceptions are allowed for some source formatting (like renaming variables or converting spaces to tabs, etc.), but for each bugfix or for each feature added, tests must be present.

Tests in Alloy are done using YUI tests, so if you want to contribute to the library, but you are not familiar with YUI tests, you may take a look here. It is quite easy, interesting, and it does not take much time. In fact, every single minute spent on making tests will repay you and our community double. In addition to YUI tests, Yeti can be used to execute the tests on multiple browsers simultaneously.

  • 1) Bugfixes need annotations;

    When tests are added (especially as part of a bug fix), in the beginning of the function there must be an annotation, pointing to the corresponding ticket, published here. For example:

     /**
      * Ensure all event listeners are destroyed properly.
      *
      * @tests AUI-1234
      */
    

Test execution

Install Yeti v0.2.27:

[sudo] npm install -g yeti

To execute all the tests in the project, please follow these instructions:

  1. Open a terminal and start a Yeti server:
yeti --server

You'll see something similar to this log:

Yeti Hub started. LAN: http://localhost:9000
                  Local: http://localhost:9000
  1. Open a terminal and connect to the Yeti instance:
cd src
yeti --junit **/tests/unit/*.html > alloy-tests.xml

The --junit parameter will generate an output file in jUnit format, which is readable by CI servers as Jenkins, Hudson, or Go.

You'll see something similar to this log:

Waiting for agents to connect at http://localhost:9000
...also available locally at http://localhost:9000
  1. Point as many browsers as you want to the Yeti server, which should run on localhost:9000. You'll see something similar to this log:
When ready, press Enter to begin testing.
  Agent connected: Chrome (39.0.2171.95) / Mac OS from 127.0.0.1
  Agent connected: Firefox (30.0) / Mac OS from 127.0.0.1
  1. Press Enter:
✓ Testing started on Chrome (39.0.2171.95) / Mac OS, Firefox (30.0) / Mac OS
► Testing... - 43% complete (68/160) 50.47 beats/sec ETA 35 seconds

And voilà! Your tests will be executed on those browsers you connected, and saved test results in a jUnit style.