1

I have a project where I would like to check test coverage for the Solidity Smart Contracts. I am using solidity-coverage via a buidler plugin and the test coverage is always 0%. The output from the tool appears to be perfectly fine, but the report yields no useful information since there are tests running for the Smart Contracts but the report returns the test coverage is 0%.

This project uses @openzeppelin/cli and not truffle.

Below are the config files and versions that I using (package.json):

"devDependencies": {
  "@nomiclabs/buidler": "^1.4.7",
  "@openzeppelin/test-environment": "^0.1.4",
  "chai": "^4.2.0",
  "ganache-cli": "^6.10.1",
  "mocha": "^8.1.3",
  "solidity-coverage": "^0.7.10"
}

The buidler.config.js file is as follows:

usePlugin('solidity-coverage')

module.exports = {
  solc: {
    version: "0.6.2"
  },
  networks: {
    coverage: {
      url: 'http://localhost:8555'
    }
  },
}

When I run the command:

npx buidler coverage --network coverage

I see the following (some content removed for brevity):

> server:            http://127.0.0.1:8555
> ganache-core:      v2.10.1
> solidity-coverage: v0.7.10

Network Info
============
> port:    8555
> network: coverage


Instrumenting for coverage...
=============================
Contract1.sol
Compiling...

Compiled 1 contract successfully
All contracts have already been compiled, skipping compilation.

...tests run here...

31 passing (10s)

------------------------|----------|----------|----------|----------|----------------|
File                    |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------|----------|----------|----------|----------|----------------|
 Contract1.sol          |        0 |        0 |        0 |        0 |                |
------------------------|----------|----------|----------|----------|----------------|
All files               |        0 |        0 |        0 |        0 |                |
------------------------|----------|----------|----------|----------|----------------|

As can be seen from the output above, everything compiles, test run (and pass) but the report concludes there is 0% test coverage (when there is).

Any help would be greatly appreciated!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.