Browse files

Improved README, fixed a few doc errors

* Updated the code example
  • Loading branch information...
1 parent 56dce72 commit 4e9017ba58619e856d90d0ea9dcc1b51fad7f56d Siddharth Mahendraker committed Dec 19, 2011
Showing with 31 additions and 12 deletions.
  1. +30 −11
  2. +1 −1 bin/srunner.js
@@ -1,8 +1,10 @@
# stest - A Sane Async Testing Framework
-Frustrated with other testing frameworks which
-kinda sucked at handling async, so I decided to make
+`stest` is a fun, fast and simple testing framework
+particularly suited towards asynchronous code. It lets
+you easily structure tests for code with both
+synchronous and asynchronous methods without too much
# Installation:
@@ -15,47 +17,61 @@ Using `npm`:
A very simple test:
var stest = require("stest"),
- assert = require("assert");
+ assert = require("assert"),
+ mylib = stest.cover("../lib/mylib");
var opts = { timeout: 0 };
stest.addCase("stest", opts,{
setup: function(promise){
promise.emit("event", 42);
promise.emit("other_event", "Hello!");
+ mylib.async_func(function(err, obj){
+ promise.emit("async", err, obj);
+ });
event: function(fortytwo){
assert.equal(42, fortytwo);
other_event: function(hello){
assert.equal("Hello!", hello);
+ async: function(err, obj){
+ assert.ifError(err);
+ assert.ok(obj);
+ },
teardown: function(errors){
if(errors.length > 0) assert.ok(0);
`stest` hands you a `promise` object which is an instance
of `EventEmitter`. Use this to emit events and values
-when your async calls complete, and check them in the
+when your async/sync calls complete, and check them in the
corresponding functions associated with the name of the
-event you emitted.
+events you've emitted.
The `setup` and `teardown` functions are given to you
-to setup your test case, and optionally, to perform
-a teardown.
+to setup your test case, and to perform a teardown.
+`setup` is required, `teardown` is optional.
The `opts` argument allows you to specify a `timeout`
in miliseconds. If all async calls are not called
-before that time, then the `stest` will give you a heads up.
+before that time, `stest` will give you a heads up.
+`stest` also supports code coverage using the `cover`
+method, which shows unseen LOC and gives you a brief
+overview of how much of the file you've tested.
-See the source for more details and documentation.
+See the source code and inline documentation for more details.
# Running Tests:
Tests can be run en masse using `srunner`:
- Usage: srunner [-s] [modules] -r [regexp]
+ Usage: srunner [-s] -r [regexp]
-s, --silent supress output [boolean]
@@ -70,6 +86,9 @@ still run tests like this:
node test.js
+`srunner` isn't dependant on `stest` per se, so it also
+works really well as a general purpose test runner.
# License:
(The MIT License)
@@ -6,7 +6,7 @@ var path = require("path"),
color = require("colors"),
optimist = require("optimist"),
argv = optimist
- .usage("Usage: $0 [-s] [modules] -r [regexp]")
+ .usage("Usage: $0 [-s] -r [regexp]")
description: "supress output",
alias: "silent",

0 comments on commit 4e9017b

Please sign in to comment.