Activate your free membership today | Log-in

Thursday, November 5th, 2009

Riot.js: JavaScript port of the lean fast unit test framework

Category: JavaScript, Testing

Riot started as a lean Ruby unit test framework with tests that have a style like this:

RUBY:
    context "a new user" do
      setup { User.new }
      asserts("that it is not yet created") { topic.new_record? }
    end

Alex Young has now implemented Riot.js which brings you the lean framework in a format that can run stand-along via Rhino, or through the browser itself with tests that look like:

JAVASCRIPT:
  1.  
  2. Riot.run(function() {
  3.   context('basic riot functionality', function() {
  4.     given('some simple equality tests', function() {
  5.       asserts('a simple truth test should return true', true).isTrue();
  6.       asserts('isNull is null', null).isNull();
  7.     });
  8.  
  9.     given('another context', function() {
  10.       asserts('equals should compare strings as expected', 'test string').equals('test string');
  11.     });
  12.  
  13.     given('a context concerned with functions', function() {
  14.       asserts('asserts() should allow functions to be compared', function() {
  15.         return 'test string';
  16.       }).equals('test string');
  17.     });
  18.   });
  19.  
  20.   given('yet another context', function() {
  21.     asserts('equals should compare strings as expected', 'test string').equals('test string');
  22.   });
  23. });
  24.  

Posted by Dion Almaer at 6:12 am
2 Comments

+----
1.5 rating from 60 votes

2 Comments »

Comments feed TrackBack URI

In February 2004, the Chinese mobile phone users reached million, the global mobile phone subscribers reached billion more. Mobile phone has become an indispensable communication tool. Mermaid Satin Tulle Wedding DressLet us look at the history of mobile phone gives us a clearer understanding of the exchangestrapless ball gown wedding dresses of information and communication technology, the pace of evolution Timeinexpensive bridesmaid dresses to pour back over years ago, the United States Morse painter in Europe to study in a way, germination of the reason for the electromagnetic telegraph transmission ofideas,Mermaid Spaghetti Satin Wedding Dress Morse invented the “Morse code” May 24, 1844. Morse’s telegraph sent from Washington to Baltimore in human history, the first telegram, “how God created a miracle!wedding dress

Comment by wuwei — November 9, 2009

^ Hilarious spam post wuwei. Failed attempt in boosting Google search ranking.

I might give Riot a try, in need of a real simple Unit Tester for js.

Comment by davidck — November 9, 2009

Leave a comment

You must be logged in to post a comment.