github.com/awsdocs/aws-doc-sdk-examples/gov2/testtools (go): Package testtools provides a set of tools to help test code that calls AWS services.  **AWS Middleware Stubber**  The AWS Middleware Stubber is a unit testing tool that hooks into the AWS SDK for Go middleware (https://aws.github.io/aws-sdk-go-v2/docs/middleware/) to short-circuit calls to AWS services, verify inputs, and return predefined outputs. This improves unit testing because you don't have to define mocks or change the way your code calls AWS. Tests run without calling AWS, which means tests run faster and don't incur charges or risk impacting your resources.  To use AwsmStubber, first create an instance of AwsmStubber.  The stubber is configured to handle all calls to AWS before the Serialize middleware step. Use the stubber config to create a service client.  Define and add all service actions that are called by your test.  During your test run, the stubber verifies that each call is made in the order that stubs are added to the stubber. The stubber also checks actual input against expected input. If the call is verified, either the specified output is returned or, if an error is requested, the error is returned.  Run your test and verify the results. Use testtools helper functions to verify errors and run exit code.  By using sub tests, you can use the same test code to test both error and non-error paths.  The testtools.ExitTest helper verifies that all expected stubs were called during the test, so if your test exits early and leaves uncalled stubs, the test fails.  **Framework**  The framework section of the package provides a set of helper functions that you can use in your tests to perform common tasks, such as verifying that errors returned from the code under test match up with the expected errors, and running exit checks to verify all stubs were called.  **Scenarios**  The scenarios section of the package provides a set of helper functions that you can use to run scenario tests. Scenarios typically string together several actions in a narrative format. The scenario test functions let you define the expected actions of your scenario as a list of stubs. Then, your test function is called first with no errors, and subsequently with each stub set to return an error.  **Mocks**  The mocks section of the package provides mocks of components that are used in the code examples, such as a mock of the IQuestioner interface that lets you specify a list of expected answers. The mock questioner returns these answers in sequence during a test to mock user input.
Keywords: aws|cpp|documentation|dotnet|examples|go|java|javascript|php|programming|python|ruby