Skip to main content

Testing NFT Contracts


Framework Description

The testing framework in this tutorial uses the Casper engine test support crate for testing the contract implementation against the Casper execution environment.

The tests source folder contains over 150 tests covering a variety of scenarios, including contract installation, minting and burning tokens, sending transfers, upgrading the contract, and listening to events.

For more details about the test framework and how each test is set up, visit the Testing Smart Contracts documentation page.

Running the Tests

To build and run the tests, issue the following command in the project folder:

make test

The project contains a Makefile, which is a custom build script that compiles the contract before running tests in release mode. Then, the script copies the contract.wasm file to the corresponding version folder in a tests/wasm directory. In practice, you only need to run the make test command during development without building the contract separately.

This example uses bash. If you use a Rust IDE, you must configure it to run the tests.