add another describe to the test to reflect the method being tested

pull/7/head
Iuri Matias 7 years ago
parent 87a7f9fbb0
commit a23965a270
  1. 108
      tests/testRunner.js

@ -23,71 +23,73 @@ function compileAndDeploy (filename, callback) {
} }
describe('testRunner', function () { describe('testRunner', function () {
describe('test with beforeAll', function () { describe('#runTest', function() {
let filename = 'tests/examples_1/simple_storage_test.sol' describe('test with beforeAll', function () {
let tests = [], results = {} let filename = 'tests/examples_1/simple_storage_test.sol'
let tests = [], results = {}
before(function (done) { before(function (done) {
compileAndDeploy(filename, function (_err, contracts) { compileAndDeploy(filename, function (_err, contracts) {
var testCallback = function (test) { var testCallback = function (test) {
tests.push(test) tests.push(test)
} }
var resultsCallback = function (_err, _results) { var resultsCallback = function (_err, _results) {
results = _results results = _results
done() done()
} }
TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback) TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback)
})
}) })
})
it('should 1 passing test', function () { it('should 1 passing test', function () {
assert.equal(results.passingNum, 1) assert.equal(results.passingNum, 1)
}) })
it('should 1 failing test', function () { it('should 1 failing test', function () {
assert.equal(results.failureNum, 1) assert.equal(results.failureNum, 1)
}) })
it('should returns 3 messages', function () { it('should returns 3 messages', function () {
assert.deepEqual(tests, [ assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest' }, { type: 'contract', value: 'MyTest' },
{ type: 'testPass', value: 'Initial value should be100', time: 1 }, { type: 'testPass', value: 'Initial value should be100', time: 1 },
{ type: 'testFailure', value: 'Initial value should be200', time: 1 } { type: 'testFailure', value: 'Initial value should be200', time: 1 }
]) ])
})
}) })
})
describe('test with beforeEach', function () { describe('test with beforeEach', function () {
let filename = 'tests/examples_2/simple_storage_test.sol' let filename = 'tests/examples_2/simple_storage_test.sol'
let tests = [], results = {} let tests = [], results = {}
before(function (done) { before(function (done) {
compileAndDeploy(filename, function (_err, contracts) { compileAndDeploy(filename, function (_err, contracts) {
var testCallback = function (test) { var testCallback = function (test) {
tests.push(test) tests.push(test)
} }
var resultsCallback = function (_err, _results) { var resultsCallback = function (_err, _results) {
results = _results results = _results
done() done()
} }
TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback) TestRunner.runTest('MyTest', contracts.MyTest, testCallback, resultsCallback)
})
}) })
})
it('should 2 passing tests', function () { it('should 2 passing tests', function () {
assert.equal(results.passingNum, 2) assert.equal(results.passingNum, 2)
}) })
it('should 0 failing tests', function () { it('should 0 failing tests', function () {
assert.equal(results.failureNum, 0) assert.equal(results.failureNum, 0)
}) })
it('should returns 3 messages', function () { it('should returns 3 messages', function () {
assert.deepEqual(tests, [ assert.deepEqual(tests, [
{ type: 'contract', value: 'MyTest' }, { type: 'contract', value: 'MyTest' },
{ type: 'testPass', value: 'Initial value should be100', time: 1 }, { type: 'testPass', value: 'Initial value should be100', time: 1 },
{ type: 'testPass', value: 'Initial value should be200', time: 1 } { type: 'testPass', value: 'Initial value should be200', time: 1 }
]) ])
})
}) })
}) })
}) })

Loading…
Cancel
Save