Evidence; that your code will work
Author: Dion Almaer
11
Nov
Tobie Langel of Prototype fame has created another unit testing library for JavaScript. Another one I hear you say? Well, if Tobie did it.... it is worth checking out. Time to get some Evidence.
I found out about it over dinner in Berlin at the great JSConf.EU. At the table were 6 people from 6 different countries. Go JavaScript diversity :) I first asked "BDD?" and Tobie spat out "No, I friggin hate BDD, especially for JS" before I had even finished the question.
Tobie gave a talk on Evidence at the show, and explained the focus of the library:
- Library agnostic (the scripty based one in Prototype was based on Prototype which is weird when you test yourself)
- Environment agnostic (e.g. not just in the browser)
- Self contained (no global pollution)
- Built with async in mind (in JS / client server / anything real, you gotta do async)
- Easy to automate
JAVASCRIPT:
-
-
Evidence.TestCase.extend('ArrayTest', {
-
setUp: function() {
-
this.array = ['foo', 'bar', 'baz'];
-
},
-
-
testFirst: function() {
-
this.assertEqual('foo', _.first(this.array));
-
this.assertUndefined(_.first([]));
-
},
-
-
testLast: function() {
-
this.assertEqual('bar', _.last(this.array),
-
'Failed to grab the last element of the array.');
-
this.assertUndefined(_.last([]));
-
}
-
});
-
Related News :