You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
#SolCover
|
|
|
|
###Installation and preparation
|
|
|
|
From your truffle directory, clone this repo:
|
|
```
|
|
git clone http://github.com/area/solcover.git
|
|
cd solcover
|
|
npm install
|
|
```
|
|
|
|
Until [Truffle allows the `--network` flag for the `test` command](https://github.com/ConsenSys/truffle/issues/239), in `truffle.js` you have to set a large gas amount for deployment. While this is set, uninstrumented tests likely won't run correctly, so this should only be set when running the coverage tests. An appropriately modified `truffle.js` might look like
|
|
|
|
```
|
|
module.exports = {
|
|
rpc: {
|
|
host: 'localhost',
|
|
gasPrice: 20e9,
|
|
gas: 0xfffffff,
|
|
}
|
|
};
|
|
```
|
|
In the future, hopefully just adding the 'coverage' network to `truffle.js` will be enough. This will look like
|
|
|
|
```
|
|
module.exports = {
|
|
rpc: {
|
|
host: 'localhost',
|
|
gasPrice: 20e9,
|
|
},
|
|
networks:{
|
|
"coverage":{
|
|
gas: 0xfffffff,
|
|
}
|
|
}
|
|
}
|
|
```
|
|
and will not interfere with normal `truffle test` - or other commands - being run during development.
|
|
|
|
|
|
###Execution
|
|
|
|
Firstly, make sure that your contracts in your truffle directory are saved elsewhere too - this script moves them and modifies them to do the instrumentation and allow `truffle` to run the tests with the instrumented contracts. It returns them after the tests are complete, but if something goes wrong, then `originalContracts` in the truffle directory should contain the unmodified contracts.
|
|
From inside the SolCover directory, run
|
|
|
|
```node ./runCoveredTests.js```
|
|
|
|
Upon completion of the tests, open the `./coverage/index.html` file to browse the HTML coverage report.
|
|
|
|
###TODO
|
|
|
|
- [ ] Turn into a true command line tool, rather than just a hacked-together script
|
|
- [ ] Release on NPM
|
|
- [ ] Do not modify the `../contract/` directory at all during operation (might need changes to truffle)
|
|
- [ ] Support for arbitrary testing commands
|
|
- [ ] [You tell me](http://github.com/area/solcover/issues)
|
|
|