From 1ff535a194125b98ce8cfb8eeb562e62c19bf52a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 21 Jun 2018 12:11:41 -0400 Subject: [PATCH] fix to avoiding duplicate passing or failing tests due to multiple asserts --- src/testRunner.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/testRunner.js b/src/testRunner.js index 6b2444fd3e..e1ffac490f 100644 --- a/src/testRunner.js +++ b/src/testRunner.js @@ -61,19 +61,26 @@ function runTest (testName, testObject, testCallback, resultsCallback) { let time = Math.ceil((Date.now() - startTime) / 1000.0) let topic = Web3.utils.sha3('AssertionEvent(bool,string)') + let testPassed = false + for (let i in receipt.events) { let event = receipt.events[i] if (event.raw.topics.indexOf(topic) >= 0) { var testEvent = web3.eth.abi.decodeParameters(['bool', 'string'], event.raw.data) - if (testEvent[0]) { - testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name), time: time, context: testName}) - passingNum += 1 - } else { + if (!testEvent[0]) { testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time, errMsg: testEvent[1], context: testName}) failureNum += 1 + return next() } + testPassed = true } } + + if (testPassed) { + testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name), time: time, context: testName}) + passingNum += 1 + } + return next() } catch (err) { console.log('error!')