track time for succeful tests

pull/7/head
Iuri Matias 7 years ago
parent 1dd1dc3cb8
commit 11ab327882
  1. 4
      index.js
  2. 11
      src/testRunner.js

@ -41,6 +41,7 @@ var runTestFiles = function (filepath, isDirectory, web3) {
function runTests (contractsToTest, contracts, next) {
let totalPassing = 0
let totalFailing = 0
let totalTime = 0
var testCallback = function (result) {
if (result.type === 'contract') {
@ -54,6 +55,7 @@ var runTestFiles = function (filepath, isDirectory, web3) {
var resultsCallback = function (_err, result, cb) {
totalPassing += result.passingNum
totalFailing += result.failureNum
totalTime += result.timePassed
cb()
}
@ -71,7 +73,7 @@ var runTestFiles = function (filepath, isDirectory, web3) {
console.log("\n")
if (totalPassing > 0) {
console.log((" " + totalPassing + ' passing').green)
console.log((" " + totalPassing + ' passing ').green + ('(' + totalTime + 's)').grey)
}
if (totalFailing > 0) {
console.log((" " + totalFailing + ' failing').red)

@ -20,17 +20,21 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
let passingNum = 0
let failureNum = 0
let timePassed = 0
testCallback({type: 'contract', value: testName})
async.eachOfLimit(runList, 1, function (func, index, next) {
let method = testObject.methods[func.name].apply(testObject.methods[func.name], [])
let startTime = Date.now()
if (func.constant) {
method.call().then((result) => {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
if (result) {
testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name)})
testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name), time: time})
passingNum += 1
timePassed += time;
} else {
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name)})
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time})
failureNum += 1
}
next()
@ -43,7 +47,8 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
}, function () {
resultsCallback(null, {
passingNum: passingNum,
failureNum: failureNum
failureNum: failureNum,
timePassed: timePassed
})
})
}

Loading…
Cancel
Save