Closed m-Peter closed 1 year ago
Hi @m-Peter! Thanks for submitting your proposal - just wanted to let you know that we've accepted your proposal and are following up directly with next steps.
Hey @chrisackermann :wave:, I have actively started development on this proposal as well. The 1st PR tackling the addition of new built-in matchers, can be found here https://github.com/onflow/cadence/pull/2420 :pray:
Excellent news @m-Peter !
Love the proposal, I Like to include the minor stuff as well like -
console.log
where I can console in the contracts and in the test file as well .. it will make the debugging a hell lot easier. @satyamakgec Much thanks for your feedback :bow:
I will certainly take these features in account, and provide an implementation for them. In fact, regarding your last bullet point about logging, I have already added this feature in https://github.com/onflow/cadence-tools/pull/109. The log
built-in function can be used in contracts/scripts/transactions and test files as well. It will be included probably in the next release :pray:
@franklywatson The repository containing usage examples about the testing framework has moved here: https://github.com/m-Peter/flow-code-coverage. This is where I will put samples for any new features.
Nice work! Closing since this is now completed
Cadence Test Framework Improvements
Grant category
Description
The Flow Emulator is the developer tool for the Flow blockchain which allows the development of Cadence smart contracts, scripts and transactions. It is bundled with the
flow-cli
tool. Among the supported commands of theflow-cli
, there is also atest
command, which runs tests written with the Cadence testing framework, while utilizing the Flow Emulator under the hood.I would like to make the Cadence testing framework more feature-rich, by implementing the features described in https://github.com/onflow/cadence/issues/1889 (
Matchers
/Unit Testing
/Integration Testing
/Deployed Contracts
/Logs & Events
)Problem statement
Testing is an essential part of the development workflow. The Cadence testing framework, as of now, has a basic set of features that makes it functional, however it needs more features to make it a fully-fledged testing framework.
Proposed solution
The
TestFramework
interface has to include the proposed API from https://github.com/onflow/cadence/issues/1889. This API has to be implemented in the Cadence testing stdlib (runtime/stdlib/test.go
) and the emulator-backed implementation (test/emulator_backend.go
). The relevant code files can be found below:Impact
Provide
test
/development
parity, by allowing developers to write unit/integration tests in Cadence (https://12factor.net/dev-prod-parity). Developers will also be able to measure how well their tests cover their contracts, and gain sufficient confidence before deploying to testnet, and more importantly on mainnet. Code coverage will be natively offered by the framework.Milestones and funding
Total Cost: 71,250 USD. Of course, I am open to discussion, regarding the cost and timeline :slightly_smiling_face: .
Team