mocha-combo
https://github.com/Tedc0819/mocha-combo
mocha-combo is a testing framework based on mocha. It generates test cases by your configuration and input. Testing with high coverage is now easy to achieve.
Testing is basically done against a test point / method. There are lots of factors / arguments that will affect the result. Instead of defining the testing condition as a whole, we can define each condition of each factor. With this new kind of definition, we can easily generate all combintaion. There will be no need to write it one by one.
This layer actually run on top of mocha. All the phases (like beforeEach) can be set up according to combination of testing factors. The result can be easily divided into success assert and failure assert according to combinations.
You can read /examples for more details. https://github.com/Tedc0819/mocha-combo/tree/master/examples
You can also read the API doc in src file https://github.com/Tedc0819/mocha-combo/blob/master/src/MochaCombo.js
Release note
0.1.0
- using cartesian-product to replace getCombinations
- using async-await
0.0.9
- The framework should still run with argument [] even there is no args and argTypes
basic example
const MochaCombo = ;const Calculator = ;const assert = assert; { super thismethodName = 'Calculator.add' thisargs = 'value' thisargTypes = value: 'integer' 'integerStr' 'string' } {} { return this; } {} {} {} {} {} {} { let argValues = value: 'integer': 1 'integerStr': "1111" 'string': "fdfafds" return argValuesargargType; } { let calculator = ; // you can attach any varible to test. so that you can access it when you assert it // test equals to 'this' in moche test function testcalculator = calculator; return calculator; } {} { let value = combination; return value == 'integer'; } { } { } let testSuite = ;testSuite;
This should generate mocha test result like this.
Calculator.add(value)
success - [integer]
✓ should work
failure - [integerStr]
✓ should not work
failure - [string]
✓ should not work
This example demonstrate some advanced features.
- the 'only' function
- the 'skip' function
- the 'extraCombinations' function
- the case that the arguments is not exactly the argument of the method
const MochaCombo = ;const Calculator = ;const assert = assert; { super thismethodName = 'Calculator.add' thisargs = 'currentValue' 'value' thisargTypes = currentValue: 'zero' 'five' 'six' // just example. it can be 'highestCapableValue', blah blah blah value: 'integer' 'integerStr' 'string' } {} { return this; } {} {} { let currentValue value = combination; return currentValue; } { let currentValue value = combination; return value; } {} { let calculator = ; testcalculator = calculator; } { let argValues = currentValue: zero: 0 five: 5 six: 6 value: 'integer': 1 'integerStr': "1111" 'string': "fdfafds" 'two': 2 return argValuesargargType; } { return 'zero' 'two' ; } { testcalculatorcurrentValue = argsValues0; return testcalculator; } {} { let currentValue value = combination; return value == 'integer' || value == 'two'; } { } { } let testSuite = ;testSuite;
This should give result like this.
Calculator.add(currentValue,value)
success - [zero, integer]
✓ should work
failure - [zero, integerStr]
✓ should not work
failure - [zero, string]
- should not work
success - [five, integer]
✓ should work
failure - [five, integerStr]
✓ should not work
failure - [five, string]
- should not work
success - [zero, two]
✓ should work