WARNING: This is an API preview! Expect major bugs, glaring omissions, and breaking changes!
This crate provides a testing framework for Interchain SDK applications
using the [ixc] crate.
See that crate for more information on getting started.
Getting Started
This framework allows you to write tests for [ixc] handlers
using regular rust #[test] functions following these basic steps:
- Add a
use ixc::testing::*statement (optional, but recommended) - Define a
TestApp - Register the handler types we want to test
- Create account instances for real or mao
- Perform actions on the accounts and assert the results
Let's define a simple counter with one method inc which increments the counter and returns
the new value:
Now we can write a test for this counter. This simple test will create a new counter, increment it and check the result.
Using Mocks
Mock handlers created by frameworks such as mockall
can be used to test the behavior of a handler in isolation.
The [MockHandler] type can be used to register boxed mock instances
of one or more [ixc::handler_api] traits.
And the [TestApp::add_mock] method can be used to add a mock handler to the test app.
See the examples/ directory in the [ixc] crate for more examples on usage.