juliandescottes/piskel — pull request #214 by juliandescottes (2014-08-24 16:53:52+00:00)
Title: Feature add tests

Summary of changes :
- updated to node 0.10
- updated most dependencies
- integrated karma/jasmine to grunt build (local & travis)
- added a drawing test recorder, player, runner, tester
- running drawing tests in CasperJS when using grunt test-local (not used on Travis)

The goal of this branch was to improve the testing of Piskel.

### Unit Testing

Karma is integrated to Piskel's build (with Jasmine as the testing framework). The tests can be found in test/js.
Only one test has been written so far : HistoryServiceTest, covering the undo/redo mechanism. Of course, since Piskel was not written with tests in mind, most of the classes cannot easily be tested as it is.

==> From now on, for each change impacting an untested class, please take the time to see what can be tested/extracted from now on :)

### Integration Testing

##### selenium
My initial goal was to use selenium to write integration tests for Piskel and to use Sauce Labs to run them. That did not go well. I was unable to record a single Selenium Test. For some reason Selenium doesn't detect the page load of Piskel. I don't know what I screwed up with the loading (maybe the billion iframes I use as templates don't mix well with Se ?).

##### record/replay
Anyway I gave up that path, and decided to write a small __record/replay__ utility. I'll write a wiki page on that topic. Using the DrawingTestRecorder can now record tests that capture : mouse events on drawing area, frame/layer changes, tool selection, color selection. In each test record is also stored the framesheet png that resulted from this series of event. These records can be regrouped in test suites. Then using the DrawingTestSuiteRunner we can rerun the test records. For each test, the events are executed and we compare the framesheet png produced by the application to the one stored in the test record.

To record and run tests, two new controllers :
- DrawingTestSuiteController, for running a test suite with a simplistic report UI
- TestRecordController for recording a test,

##### impacts
Everything related to the test recording is in src/devtools. During the packaging step, these files are filtered out. This means that the packaged and packaged-min versions of Piskel are not embedding the devtools. They are only available in debug mode.

##### testing status

I recorded a first suite of tests to get started, they are located in `test/integration/casperjs/drawing-records`. They cover all the tools we have for now (except lighten and selection tool) + a few use cases involving frames and layers.

These tests are run with CasperJS when using `grunt test-local`. A new CasperJS test is responsible for launching them : `test/integration/casperjs/DrawingTest.js`.

They are not triggered during the travis build because they simply don't work on travis. I have no idea why yet.

##### what remains ?

- write wiki page : Piskel test guidelines
- improve Drawing Record Replay UIs
- write more unit tests as development goes on
- add integration tests for settings panel (if unit tests are not enough)
- support history events for record/replay
- add drawing tests to continuous integration