Running scenarios
Most of the MultiversX smart contract testing infrastructure is built with scenarios in mind, so there are lots of ways to execute them.
Assume we have a scenario JSON file. The options for running it are:
- using the
run-scenarios
standalone tool - generating some tests in a Rust project and running the Rust tests.
Standalone tool
The only standalone tool for running scenarios is run-scenarios
, part of the VM tooling.
The binary is build from here. Most of the code lies here, if you're curious.
To call, simply run run-scenarios <path>
, where the path can be either a speciific scenario file, or a folder containing scenarios. In the case of a folder, the tool will run all files ending in *.scen.json
. Results are printed to console.
Integration in Rust
We normally want to integrate scenario tests in the CI. For this, at the very least we should write Rust tests that run the scenarios.
We have decided to have a separate Rust test for each scenario file. This way, when running a full test suite, it is easy to see exactly what test has failed, at a glance:
We also want to have a set of such tests for each of the backends: Go and Rust.
Standard project layout
The standard for organising tests in a Rust crate is a follows:
├── Cargo.toml
├── meta
├── multiversx.json
├── output
├── scenarios
│ ├── scenario1.scen.json
│ └── scenario2.scen.json
├── src
│ └── my_contract.rs
├── tests