Now that we have a new project, we can add a Rust integration test using a cargo generate template.
If cargo generate is not already installed, you can instal it with:
cargo install cargo-generate
Icon InfoCircle
Note You can learn more about cargo generate by visiting its repository Icon Link.
Let's generate the default test harness with the following command:
--force forces your --name input to retain your desired casing for the {{project-name}} placeholder in the template. Otherwise, cargo-generate automatically converts it to kebab-case. With --force, this means that both my_fuel_project and my-fuel-project are valid project names, depending on your needs.
Before running test, we need to build the Sway project with:
forc build
Afterwards, we can run the test with:
cargo test
Icon InfoCircle
Note If you need to capture output from the tests, use one of the following commands:
Another way to experience the SDK is to look at the source code. The packages/fuels/tests/ folder is full of integration tests that go through almost all aspects of the SDK.
Icon InfoCircle
Note Before running the tests, we need to build all the Sway test projects. The file packages/fuels/Forc.toml contains a `[workspace], which members are the paths to all integration tests.
To build these tests, run the following command:
forc build --path packages/fuels
Icon InfoCircle
forc can also be used to clean and format the test projects. Check the help output for more info.
After building the projects, we can run the tests with
cargo test
If you need all targets and all features, you can run
cargo test --all-targets --all-features
Icon InfoCircle
Note If you need to capture output from the tests, you can run