Wednesday, August 30th, 2006
Script.aculo.us Behaviour Driven Development Testing
<>p>Thomas Fuchs has added some new features to the script.aculo.us test library that borrow from Behaviour Driven Development.-
-
Test.context("BDD-style testing",{
-
'should automatically add extensions to strings': function(){
-
'a'.shouldEqual('a');
-
'a'.shouldNotEqual('b');
-
'a'.shouldNotBeNull();
-
'a'.shouldBeA(String);
-
'a'.shouldNotBeA(Number);
-
}
-
});
-
Basically, you’re defining a context for which one or more specifications should be asserted. Note the easy readability, and the added value by using a string to describe the test/specification, giving you the advantage of having better documentation for your JavaScript libraries.
Of course, setup and teardown is also supported, as are all normal assert* methods.
This appears to have made it into the recent Prototype changes too.
Related Content:











Things like this make me happy. *HEART BDD*
Like me mate Ali G says:
RESPEC!
[...] http://ajaxian.com/archives/scriptaculous-behaviour-driven-development-testing [...]
Currently(v1.7.1b3), script.aculo.us BDD framework doesn’t support IE. But it can be easily fixed. Just edit line 530 from this:
‘function(){‘+
to this:
‘x = function(){‘+
I hope it will help.