6

I'm trying to make a test coverage for MetaCoin. This is my package.json, truffle-config.js and
.solcover.js:

module.exports = {
    port: 8555,
    norpc: true,
    compileCommand: '../node_modules/.bin/truffle compile',
    testCommand: '../node_modules/.bin/truffle test --network coverage'
};

I run the commands ./node_modules/.bin/ganache-cli --port 8555 --gasLimit 0xfffffffffff and ./node_modules/.bin/solidity-coverage and the result is an empty test coverage:

Generating coverage environment
Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle compile --network coverage
(this can take a few seconds)...
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Writing artifacts to ./build/contracts

Instrumenting  ./coverageEnv/contracts/ConvertLib.sol
Instrumenting  ./coverageEnv/contracts/MetaCoin.sol
Skipping instrumentation of  ./coverageEnv/contracts/Migrations.sol
Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle compile --network coverage
(this can take a few seconds)...
Compiling ./contracts/ConvertLib.sol...
Compiling ./contracts/MetaCoin.sol...
Compiling ./contracts/Migrations.sol...
Writing artifacts to ./build/contracts

Running: node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage
(this can take a few seconds)...
Using network 'coverage'.

Compiling ./test/TestMetacoin.sol...


  TestMetacoin
    ✓ testInitialBalanceUsingDeployedContract (89ms)
    ✓ testInitialBalanceWithNewMetaCoin (85ms)

  Contract: MetaCoin
    ✓ should put 10000 MetaCoin in the first account
    ✓ should call a function that depends on a linked library (54ms)
    ✓ should send coin correctly (128ms)


  5 passing (8s)

-----------------|----------|----------|----------|----------|----------------|
File             |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-----------------|----------|----------|----------|----------|----------------|
 contracts/      |        0 |        0 |        0 |        0 |                |
  ConvertLib.sol |        0 |      100 |        0 |        0 |              6 |
  MetaCoin.sol   |        0 |        0 |        0 |        0 |... 23,24,28,32 |
-----------------|----------|----------|----------|----------|----------------|
All files        |        0 |        0 |        0 |        0 |                |
-----------------|----------|----------|----------|----------|----------------|

Istanbul coverage reports generated
Cleaning up...
Done. 

I get the same result if I check without tests .

Maybe I'm doing something wrong. Please help me.

2
  • Could you share the contents of your .solcover.js file? Sep 18, 2019 at 8:58
  • could you show your test file code? Inferring from the test descriptions, it looks like you do a lot of checks on balances, but might not be calling many functions. Sending funds and checking balances doesn't traverse or tickle your code. You'd need to be calling functions that execute your code in your contracts, which is what coverage measures. that's assuming you still care. It's been a while :-p
    – sola24
    Sep 8, 2022 at 20:35

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.