Shift-Left Workload, leveraging AI for Test Creation
How Amazon Q can automate test creation for faster, higher quality delivery



TestVPCCreation
: This class contains unit tests for individual functions that create VPC resources, such as VPC, Internet Gateway, Route Table, and Subnet. Each test method mocks theboto3
resource and verifies the correct method calls and return values.TestVPCIntegration
: This class contains an integration test that creates and verifies the correct creation of all VPC resources in sequence.
- Early Testing: It focuses on unit testing the individual functions responsible for VPC creation (
create_vpc
,create_internet_gateway
, etc.). This allows catching errors early in the development process, before they become part of a larger integrated system. - Isolation: By mocking the
boto3.resource
function, the unit tests isolate the functionality of the code and ensure it works as expected regardless of actual AWS interaction. This simplifies debugging and reduces reliance on complex AWS environments for testing. - Focus on Functionality: The tests verify if the functions call the appropriate boto3 methods with expected arguments. This ensures the code interacts with AWS services correctly without directly creating resources or requiring access keys.
- Repeatability and Maintainability: Unit tests allow for repeatable and automated testing, making it easier to identify regressions during future development. This improves the overall maintainability of the code.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.