JoinColony / solcover

Code coverage for solidity
MIT License
64 stars 8 forks source link

Unit test suite proposal #7

Closed cgewecke closed 7 years ago

cgewecke commented 7 years ago

What follows is an outline for one approach to developing solcover's test suite. (Not wedded to any of it - additions / deletions / modifications are more than welcome ). Also submitting a draft PR with this issue because having a larger test base might make it easier to evaluate both this idea and some of the other recently proposed changes.

Under this proposal the test directory structure would look something like this:

|-- test
   |-- util
        |-- util.js 
   |-- sources 
        |-- function
             |-- abstract.sol
             |-- empty-body.sol
             |-- ...
        |-- if
             |-- if-with-brackets.sol
             |-- if-without-brackets.sol
             |-- ...
        |-- zeppelin
             |-- Killable.sol
             |-- Shareable.sol
             |-- ...
        |-- ...
   |-- if.js
   |-- function.js
   |-- ...

A typical unit test that checks compilation would look like this:

it('should compile after instrumenting if statements with brackets',function(){
    var contract = util.getCode('if/if-with-brackets.sol');
    var info = getInstrumentedVersion(contract, "test.sol", true);
    var output = solc.compile(info.contract, 1); 
    util.report(output.errors);
})
cgewecke commented 7 years ago

Closing via #8