You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
JavaScript
54 lines
1.3 KiB
JavaScript
4 years ago
|
'use strict';
|
||
|
|
||
|
const tests = require('./sum.test');
|
||
|
const { SumTestSuite } = require('./SumTestSuite');
|
||
|
|
||
|
function runTestFile() {
|
||
|
const results = {};
|
||
|
|
||
|
Object.entries(tests).forEach(
|
||
|
([_, testData]) => {
|
||
|
console.log(testData.description);
|
||
|
try {
|
||
|
testData.test();
|
||
|
console.log('SUCCESS');
|
||
|
|
||
|
// FIXME no
|
||
|
results[testData.description] = null;
|
||
|
} catch (err) {
|
||
|
console.log('FAILED');
|
||
|
console.log(err.message);
|
||
|
results[testData.description] = err;
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
|
||
|
return results;
|
||
|
}
|
||
|
|
||
|
function runTestSuite() {
|
||
|
const suite = new SumTestSuite();
|
||
|
const suiteProto = Object.getPrototypeOf(suite)
|
||
|
const testMethodNames =
|
||
|
Object.getOwnPropertyNames(suiteProto).filter(
|
||
|
prop =>
|
||
|
typeof suite[prop] === 'function' &&
|
||
|
prop.startsWith('test')
|
||
|
);
|
||
|
|
||
|
testMethodNames.forEach(
|
||
|
testMethodName => {
|
||
|
console.log(testMethodName);
|
||
|
try {
|
||
|
suite[testMethodName]();
|
||
|
console.log('SUCCESS');
|
||
|
} catch (err) {
|
||
|
console.log('FAILED');
|
||
|
console.log(err.message);
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
runTestSuite();
|