1.0.11 • Published 9 years ago

unit_test v1.0.11

Weekly downloads
50
License
-
Repository
github
Last release
9 years ago

Installation

$ [sudo] npm install unit_test

Usage

Create a file for your unit tests and run it with node from the command line with an optional number as a parameter for how many times to run each unit test.

Run each test once
$ node unittest.js
Run each test 10 times
$ node unittest.js 10

Methods

unit_test.test(string, callback)

Creates a unit test that will be added to the queue. The string will be the name of the unit test and the test code should be inside the callback

unit_test.passed()

At any point during the callback calling the passed method will mark the test as passed and move onto the next test in the queue

unit_test.failed()

At any point during the callback calling the failed method will mark the test as failed and move onto the next test in the queue. It can be useful to wrap the entire callback in a try catch with a failed method call inside the catch block.

unit_test.start()

Call the start method at the end of your unit test file, this will push all of your unit tests into a queue and start running the tests.

Example test file

var unittest = require('unit_test'),
    assert = require('assert'),
    passed = unittest.passed,
    failed = unittest.failed,
    test = unittest.test;

// Passing test
test("ASSERT 1 == 1", function() {
    try {
        assert.ok(1 == 1)
        passed()
    } catch (err) {
        failed()
    }
})

// Failing test
test("ASSERT 1 == 10", function() {
    try {
        assert.ok(1 == 10)
        passed()
    } catch (err) {
        failed()
    }
})

unittest.start()
1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago