Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 164 lines (129 sloc) 6.669 kb
e149bd0 Basic Readme file
Joel Plane authored
1 TestNode
2 ========
3
4 A testing library/framework for Node.js
5
6 TestNode aims to be unobtrusive and unassuming about the environment
7 in which it will run. That's the goal - we will no-doubt fall short
8 of this goal somewhere, but we'll try our best.
9
10 It's a BDD-esc library in it's syntax, but that's about as far as it
11 goes in terms of BDD.
12
35b796d Joel Plane Output example in README
joelplane authored
13 Usage and Example
14 -----------------
e149bd0 Basic Readme file
Joel Plane authored
15
16 **Executing tests**:
17
18 node examples/basicTest.js
19
3ef3d51 Joel Plane `nodetest` executable tests runner
joelplane authored
20 OR
e149bd0 Basic Readme file
Joel Plane authored
21
22 testnode testsDirectory
23
35b796d Joel Plane Output example in README
joelplane authored
24 **Basic Syntax**:
25
26 ```javascript
27 var test = require('testnode')();
28 test.onFailureExitNonZero();
29
30 test.context("Example Test Suite", function() {
31 this.context("Example Sub-Context", function() {
32 this.it("should run a basic example test", function(test) {
33 test.assert(true);
34 test.done();
35 });
36 });
37 });
38 ```
39
40 **Output**:
41
42 ```
43 Example Test Suite
44 Example Sub-Context
45 it should run a basic example test
46 +
47 1 assertion passed
48 ```
49
e149bd0 Basic Readme file
Joel Plane authored
50 See the examples directory for more examples.
51
52 Installation
53 ------------
54
55 Install with npm:
56
57 npm install testnode
58
59 More doco coming soon :)
60
a63dca0 Joel Plane Added output of "testnode examples" to README
joelplane authored
61 Example Output
62 --------------
63
64 (has colour, which is not shown here)
65
66
67 joel@joel3:/usr/local/lib/node/testnode$ testnode examples/passing
68 Loading file /usr/local/lib/node/.npm/testnode/0.1.4/package/examples/passing/basicTest.js
69 Loading file /usr/local/lib/node/.npm/testnode/0.1.4/package/examples/passing/basicTest2.js
70 Loading file /usr/local/lib/node/.npm/testnode/0.1.4/package/examples/passing/setupAndTeardown.js
71 Example Test Suite
72 Example Sub-Context
73 it Basic Test Example
74 +
75 1 assertion passed
76 it Another Basic Test Example
77 +
78 1 assertion passed
79 Example of using run() for setup and teardown
80 it Test run callback has been called
81 +
82 1 assertion passed
83 it Test run() has been called once, followed by a test
84 +
85 1 assertion passed
86 setupAndTeardown.js: a = 2
87 Another context
88 it Previous context's last run() function was called
89 +
90 1 assertion passed
91
92
93 joel@joel3:/usr/local/lib/node/testnode$ testnode examples/failing
94 Loading file /usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/asyncExample.js
95 Loading file /usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/exceptionTest.js
96 Loading file /usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/failingTest.js
97 Example Test Suite
98 Example Sub-Context
99 it Test code throws exception
100 1 assertion failed
101
102 Error: bleh
103 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/exceptionTest.js:7:19)
104 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
105 at Object.next (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:22:13)
106 at Object.put (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:10:11)
107 at Array.1 (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:40:19)
108 at EventEmitter._tickCallback (node.js:170:26)
109
110 it A Failing Test Example
111 x
112 1 assertion failed
113
114 assert : Expected first argument to evaluate to true
115 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/failingTest.js:7:18)
116 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
117 at Object.next (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:22:13)
118 at Object.put (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:10:11)
119 at Array.2 (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:40:19)
120 at EventEmitter._tickCallback (node.js:170:26)
121
122 A Sub-Context in asyncExample.js
123 it should do something 2
124 +++
125 3 assertions passed
126 it should do something else
127 +x
128 1 assertion failed
129
130 assert : Expected first argument to evaluate to true
131 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/asyncExample.js:30:22)
132 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
133 at Object.next (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:22:13)
134 at [object Object].<anonymous> (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:18:13)
135 at [object Object].<anonymous> (events.js:81:20)
136 at Object._onTimeout (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:52:16)
137 at Timer.callback (timers.js:83:39)
138
139 it should do something 1
140 +xx
141 2 assertions failed
142
143 assert : Expected first argument to evaluate to true
144 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/asyncExample.js:10:24)
145 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
146 at Object.next (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:22:13)
147 at [object Object].<anonymous> (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:18:13)
148 at [object Object].<anonymous> (events.js:81:20)
149 at [object Object].done (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:52:16)
150 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/asyncExample.js:31:22)
151 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
152
153 assertEqual : Expected '123', but got 135
154 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/asyncExample.js:11:24)
155 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
156 at Object.next (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:22:13)
157 at [object Object].<anonymous> (/usr/local/lib/node/.npm/testnode/0.1.4/package/testQueue.js:18:13)
158 at [object Object].<anonymous> (events.js:81:20)
159 at [object Object].done (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:52:16)
160 at [object Object]._testFunction (/usr/local/lib/node/.npm/testnode/0.1.4/package/examples/failing/asyncExample.js:31:22)
161 at [object Object]._call (/usr/local/lib/node/.npm/testnode/0.1.4/package/test.js:56:30)
162
163
Something went wrong with that request. Please try again.