onflow/cadence-tools

[Test] Code coverage reporting for integration tests

Closed this issue · 1 comments

Problem

Running integration tests with code coverage enabled, does not collect/report any coverage metrics, due to the fact that the EmulatorBackend used the the test framework, has no CoverageReport object.

Steps to Reproduce

flow test --cover foo.cdc

Where foo.cdc uses something like:

pub var blockchain = Test.newEmulatorBlockchain()
var arrayUtils = Test.readFile("ArrayUtils.cdc")
var err = blockchain.deployContract(
    name: "ArrayUtils",
    code: arrayUtils,
    account: account,
    arguments: []
)

to deploy a contract on an account.

Acceptance Criteria

The above command should generate a valid coverage report and message, e.g:

Coverage: 55.5% of statements

for the contracts/scripts/transactions that were exercised during an integration test.

Context

This is part of an ongoing grant proposal: onflow/flow-emulator#333

Closing this as it is fixed by #95