[Sugar-devel] Unit tests in Sugar HTML

Manuel Quiñones manuq at laptop.org
Tue May 14 08:15:30 EDT 2013


2013/5/13 Daniel Narvaez <dwnarvaez at gmail.com>:
>
>
> On Monday, 13 May 2013, Manuel Quiñones wrote:
>>
>> 2013/5/13 Daniel Narvaez <dwnarvaez at gmail.com>:
>> > I'm on a phone so I have not yet taken a proper look. Though it looks
>> > pretty
>> > cool. It seems to have custom browsers support, so it should be easy to
>> > run
>> > it in sugar-html-activity.
>> >
>> > We can look at hooking this up in sugar-build/buildbot, it should not be
>> > a
>> > lot of work.
>> >
>> > I suppose it should work for the libraries too if we just put some HTML
>> > in
>> > the test dir.
>>
>> Yes the idea is to add unit tests in each of our libraries.  I did it
>> in lib/sugar-html-graphics inside clockjs code to get a first
>> impression, but I will move it to sugar-html-graphics repository if we
>> agree using Jasmine.
>
>
> Maybe a quick comparison with mocha (used by firefox os) would be worth it,
> since karma can run mocha tests too. I wouldnt spend too much time on it
> though.

Yes I agree, I will give a look to Mocha.  Maybe QUnit too.

>>
>>
>> So the proposal would be:
>>
>> - start writting unit tests with Jasmine framework
>
>
> Yes!
>
>>
>> - add a command to sugar-build to run the tests with Karma
>
>
> Yeah, we can use the check command and run karma for the js modules.
>
>>
>> - automate tests adding Karma to buildbot
>
>
> Which should just work if we use the check command.
>
> Something else I would like to provide is a way to take screen snapshots.
> The tests could request the webview to generate a snapshot with a certain id
> (we could use an alert with a well known text, in lack of a better
> communication mecanism, could be done more cleanly with a plugin but
> probably not worth it for tests). At the end of test run, the runner would
> compare the snapshots with those in test/snapshot and complain about
> differences. It's trivial to implement and should be pretty useful for
> testing visual stuff.

The thing is, in the Karma server you don't see you web application, but this:

http://dev.laptop.org/~manuq/karma.png

The real information appears in the command line:

[sugar-build sugar-html-graphics-manuq]$ karma start
INFO [karma]: Karma server started at http://localhost:9876/
INFO [Chrome 26.0 (Linux)]: Connected on socket id VrmGeTEdSMYWd82R6Emw
Chrome 26.0 (Linux): Executed 2 of 2 SUCCESS (0.517 secs / 0.021 secs)

and the good thing is that by default it will watch your JS files for
changes and run the tests again.  That's why I was thinking in a new
sugar-build command.  Of course the auto-run can be switched off and
then the check can be added to make check, I'm +1 to that.

--
.. manuq ..


More information about the Sugar-devel mailing list