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

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

Loading…
Cancel
Save