Adding unit testing to your Amazon SDK for Rust application - Amazon SDK for Rust
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Adding unit testing to your Amazon SDK for Rust application

While there are many ways you can implement unit testing in your Amazon SDK for Rust project, there are a few that we recommend:

  • Unit testing using mockall – Use automock from the mockall crate to automatically generate and execute your tests.

  • Static replay – Use the Amazon Smithy runtime's StaticReplayClient to create a fake HTTP client that can be used instead of the standard HTTP client that is normally used by Amazon Web Services services. This client returns the HTTP responses that you specify rather than communicating with the service over the network, so that tests get known data for testing purposes.

  • Unit testing using aws-smithy-mocks – Use mock and mock_client from the aws-smithy-mocks crate to mock Amazon SDK client responses and to create mock rules that define how the SDK should respond to specific requests.