Allow returning more than one Assert per function

pull/3094/head
yann300 7 years ago
parent 8cbc8dfc70
commit 9fa9f77501
  1. 28
      src/testRunner.js

@ -59,37 +59,27 @@ function runTest (testName, testObject, testCallback, resultsCallback) {
method.send().on('receipt', function (receipt) {
try {
let time = Math.ceil((Date.now() - startTime) / 1000.0)
// if (func.type === 'test') {
let topic = Web3.utils.sha3('AssertionEvent(bool,string)')
let matchingEvents = []
for (let i in receipt.events) {
let event = receipt.events[i]
if (event.raw.topics.indexOf(topic) >= 0) {
matchingEvents.push(web3.eth.abi.decodeParameters(['bool', 'string'], event.raw.data))
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 {
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time, errMsg: testEvent[1], context: testName})
failureNum += 1
}
}
}
if (matchingEvents.length === 0) {
return next()
}
let result = matchingEvents[0]
if (result[0]) {
testCallback({type: 'testPass', value: changeCase.sentenceCase(func.name), time: time, context: testName})
passingNum += 1
} else {
testCallback({type: 'testFailure', value: changeCase.sentenceCase(func.name), time: time, errMsg: result[1], context: testName})
failureNum += 1
}
// }
return next()
} catch (err) {
console.log('error!')
console.dir(err)
return next(err)
}
next()
}).on('error', function (err) {
next(err)
})

Loading…
Cancel
Save