Suitest
Suitest is a powerful and easy-to-use JavaScript BDD test suite
- Very simple to use
- Minimum functions and maximum capacity
- Client-side and server-side (including Node.js) support
- One of the most lightweightest libraries for unit testing
- Support for working with asynchronous code
- Outline function callbacks!
- Modular system
- Fluent interface support (chaining)
BDD practices:
Behavior-driven development (or BDD) is an agile software development technique devised by Dan North as a response to the issues encountered teaching test-driven development.
The practices of BDD include:
- Establishing the goals of different stakeholders required for a vision to be implemented
- Drawing out features which will achieve those goals using feature injection
- Involving stakeholders in the implementation process through outside–in software development
- Using examples to describe the behavior of the application, or of units of code
- Automating those examples to provide quick feedback and regression testing
- Using 'should' when describing the behavior of software to help clarify responsibility and allow the software's functionality to be questioned
- Using 'ensure' when describing responsibilities of software to differentiate outcomes in the scope of the code in question from side-effects of other elements of code.
- Using mocks to stand-in for collaborating modules of code which have not yet been written
Synopsis
Add a test to run
;
*A comparison assertion*
;
*Register a callback to fix test result*
;
*Add test description*
;
*Register outline function callbacks*
;
*Throws an exception when test run and stop all next tests*
;
*A boolean assertion*
;
*Register a final callback whenever all the tests have finished running*
;
Installation
Downloading
Choose one of the ways to download the Suitest:
npm
sudo npm install -g suitest
git
git clone git://github.com/monolithed/Suitest.git
zip/gzip
https://github.com/monolithed/Suitest/downloads
Server-side including
var Suitest = ;
Client-side including
Using
var unit = 'Module name';
Screenshot
API
.test ( name, callback, [, context ] );
var unit = ; unit;
.exec ( x, [, y, context ] );
Using with one parameter:
unit; // true
Using with two parameter:
unit; // true, because default operation is ==
Using with three parameters:
unit; // false, because true and 1 are not equivalent
.done ( [ callback ] );
Simple using:
unit;
Testing asynchronous code:
unit;
.describe ( description );
unit;
.finish ( [callback, [total, filed, passed, time] );
unit; unit; unit; // Total: 6, Filed: 2, Passed: 4, Time: 1.00
.stop ();
unit;
.is ()
unit;unit; // true
.get ( name );
Outline function callback
var { return unit ;};
Simple using
unit;
Using with asynchronous code
unit;
Function.prototype.bind / Function.prototype.call
Also you can use it without <get> method (but this not recommended):
var { return this ;}; unit;
Context
There're several ways to set the calling context
this
unit;
parameter
unit;
.get()
var { return unit;}; unit;
.call/apply/bind()
var { return this;}; unit;
Chaining (Fluent interface)
var unit = ; unit ;
Operators
==
operator is used by default and for most operations, you can miss it:
unit;
You can also specify it explicitly:
unit;
Other available operators:
===
, !==
, !==
, !=
, <
, >
, <=
, >=
, eq
Special eg
operator for egal comparison.
The internal comparison abstract operation SameValue(x, y), where x and y are ECMAScript language values, produces true or false (ECMAScript 5 9.12).
unit; // trueunit; // falseunit; // falseunit; // false
License
-
Suitest is licensed under the MIT (MIT_LICENSE.txt) license
-
Copyright (c) 2012 Alexander Guinness