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 themockall
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
andmock_client
from theaws-smithy-mocks
crate to mock Amazon SDK client responses and to create mock rules that define how the SDK should respond to specific requests.