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.
- HelloWorld (opens in a new tab)
- MultisigWallet (opens in a new tab)
- Crowdsale (opens in a new tab)
- IRC3Token (NFT) (opens in a new tab)
- IRC2BurnableToken (opens in a new tab)
- SampleToken (opens in a new tab)
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.
- MultisigWallet (opens in a new tab)
- Crowdsale (opens in a new tab)
- IRC3Token (NFT) (opens in a new tab)
Use integrationTest
task to run the integration testing. Here is the example of invoking the MultisigWallet integration testing.
$ ./gradlew multisig-wallet:integrationTest