TAF
TAF is a test runner for JavaScript.
Getting started
Install TAF
npm install -g taf
1. Simple tests
1.1 Create tests in tests folder
Each test method name should start with test.
const assert = { return async { assert } } { return async { assert } } { return async { throw Error'AlwaysBrokenTest' } } moduleexports = TestOne
1.2 Run tests
taf --tests ./tests
2. Tests with properties
2.1 Create tests with properties
const assert = { testPropertiesseverity = 'Blocker' return async { assert } } { testPropertiesseverity = 'Major' return async { assert } } { testPropertiesseverity = 'Minor' return async { throw Error'AlwaysBrokenTest' } } moduleexports = TestTwo
2.2 Create test suite blocker.suite in suites folder
By default tests are run in one thread, to override this setting add threadCount to test suite.
To select tests which have severity Blocker define query method. This method will be called with tests parameter which is array of all tests from tests folder. This method should return array of tests to be run as suite.
moduleexports = threadCount: 2 { return tests }
2.3 Run test suite
taf --tests ./tests --suite ./suites/blocker.suite.js
3. Tests with context
3.1 Create tests with context
Each test body is now have testContext parameter. This parameter is object passed to each test.
const assert = { testPropertiesseverity = 'Blocker' testPropertieswithContext = true return async { const value = testContext assert } } { testPropertiesseverity = 'Major' testPropertieswithContext = true return async { const value = testContext assert } } moduleexports = TestThree
3.2 Create context provider
Context provider class should have getContext method. This method will be called with context parameter which contains default context. In this method we can extend the default context by adding more properties. For this example the property is value. Method getContext is going to be called before each test and result of this method will be injected into test.
{ contextvalue = 1 return context } moduleexports = TestContext
3.3 Create test suite context.suite in suites folder
moduleexports = threadCount: 2 { return tests }
3.4 Run test suite with context
taf --tests ./tests --suite ./suites/context.suite.js --context ./context/test.context.js
4. Configuration
It is possible to put all command-line arguments into config file.
4.1 Create config file
moduleexports = tests: './tests' suite: './suites/context.suite' context: './context/test.context'
4.2 Run tests
taf --config config.js
5.Examples
See code for this Getting Started: https://github.com/georgiik/taf_examples