|
|
|
@ -37,7 +37,7 @@ do any configuration. If your tests depend on logic added to `truffle.js` - for |
|
|
|
|
uses the file to expose a babel polyfill that its suite needs to run correctly - you can override the |
|
|
|
|
default behavior by specifying a coverage network in `truffle.js`. |
|
|
|
|
|
|
|
|
|
Example coverage network config |
|
|
|
|
**Example coverage network config** |
|
|
|
|
```javascript |
|
|
|
|
module.exports = { |
|
|
|
|
networks: { |
|
|
|
@ -57,6 +57,26 @@ module.exports = { |
|
|
|
|
}; |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
You can also create a `.solcover.js` config file in the root directory of your project and specify |
|
|
|
|
some additional options: |
|
|
|
|
+ **port**: <Number> The port you want Solcover to run testrpc on / have truffle connect to. |
|
|
|
|
+ **testrpcOptions**: <String> A string of options to be appended to a command line invocation |
|
|
|
|
of testrpc. Ex: `--account="0x89a..f',10000" --port 8777`". If you use this option specify the port |
|
|
|
|
in your testrpcOptions string AND as a `port` option. |
|
|
|
|
+ **testCommand**: <String> By default Solcover runs `truffle test` or `truffle test --network coverage`. |
|
|
|
|
`testCommand` let you run tests some other way: ex: `mocha --timeout 5000`. If you're doing this, you |
|
|
|
|
will probably need to make sure the web3 provider for your tests explicitly connects to the port solcover's |
|
|
|
|
testrpc is set to run on, e.g: `var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8555"))` |
|
|
|
|
|
|
|
|
|
**Example .solcover.js config file** |
|
|
|
|
``` |
|
|
|
|
module.exports = { |
|
|
|
|
port: 6545, |
|
|
|
|
testrpcOptions: '-p 6545 -u 0x54fd80d6ae7584d8e9a19fe1df43f04e5282cc43', |
|
|
|
|
testCommand: 'mocha --timeout 5000' |
|
|
|
|
}; |
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
### Known Issues |
|
|
|
|
|
|
|
|
|
**Hardcoded gas costs**: If you have hardcoded gas costs into your tests some of them may fail when using SolCover. |
|
|
|
@ -74,11 +94,22 @@ implements a simplified search algorithm for node_modules packages |
|
|
|
|
Because Solcover copies an instrumented version of your project into a temporary folder, `require` |
|
|
|
|
statements handled by Truffle internally don't resolve correctly. |
|
|
|
|
|
|
|
|
|
**Coveralls / CodeCov**: These CI services take the Istanbul reports generated by Solcover and display |
|
|
|
|
line coverage. Istanbul's own html report provides significantly more detailed |
|
|
|
|
reporting and can show whether your tests actually cover all the conditional branches |
|
|
|
|
in your code. It can be found inside the `coverage` folder at `index.html` after you run the tool. |
|
|
|
|
|
|
|
|
|
### Examples |
|
|
|
|
|
|
|
|
|
+ **zeppelin-solidity at commit 453a19825013a586751b87c67bebd551a252fb50** |
|
|
|
|
+ **Metacoin**: The default truffle project |
|
|
|
|
+ [HTML reports](https://sc-forks.github.io/metacoin/) |
|
|
|
|
+ [Metacoin with Solcover installed](https://github.com/sc-forks/metacoin) (simple, without configuration) |
|
|
|
|
+ **zeppelin-solidity** at commit 453a19825013a586751b87c67bebd551a252fb50 |
|
|
|
|
+ [HTML reports]( https://sc-forks.github.io/zeppelin-solidity/) |
|
|
|
|
+ [Zeppelin with Solcover installed](https://github.com/sc-forks/zeppelin-solidity) (declares own coverage network in truffle.js) |
|
|
|
|
+ **numeraire** at commit 5ac3fa432c6b4192468c95a66e52ca086c804c95 |
|
|
|
|
+ [HTML reports](https://sc-forks.github.io/contract/) |
|
|
|
|
+ [Numeraire with Solcover installed](https://github.com/sc-forks/contract) (uses .solcover.js) |
|
|
|
|
|
|
|
|
|
### TODO |
|
|
|
|
|
|
|
|
|