Testing smart contracts

Testing tools and libraries

Two testing frameworks are provided as to be used for different purposes: one is for unit testing and the other is for integration testing.

Unit testing

The javaee-unittest (opens in a new tab) artifact is used to perform unit testing.

Here are the sample unit test cases.

Integration testing

The testinteg subproject can be used for the integration testing. It assumes there is a running ICON network (either local or remote) that can be connected for the testing. It uses the ICON Java SDK (foundation.icon:icon-sdk:2.0.0) to interact with the network. The default configuration (opens in a new tab) is for gochain-local (opens in a new tab) network. If you want to change this configuration, either modify the configuration file directly or set the proper system property (env.props) when you run the integration testing (see example (opens in a new tab)).

Here are the sample integration test cases.

Use integrationTest task to run the integration testing. Here is the example of invoking the MultisigWallet integration testing.

$ ./gradlew multisig-wallet:integrationTest
CTRL + K