tc

Simple test case runner

Test case runner.

Create directory with testCases. Each file with testCase must contains '.case.' in name.

caseDir/
  tc.config.js //optional
  A.case.js
  B.case.js
//in
test case text (js code by default)
//out
expected result

For example:

//in 
out(2 + 2);
out(2 * 2);
//out 
4
4

Function 'out' accumulates results. Each call create new line.

Run testCases from command line:

tc caseDir

or from js:

require('ts').run(caseDir);

Config file should be returned object with next fields:

  • exec(inText, out, collback) - function executed testCase. 'inText' is text form case between '//in' and //out. 'out' is function accumulates results. 'collback' should be called for finish test.
  • [beforeEach] - function called before each testCase
  • [afterEach] - function called after each testCase

For example:

{
    execfunction (inTextoutcallback) {
        out('\'' + inText + '\'');
        callback();
    }
}

See examples in test directory.