class IntegTest (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.IntegTests.Alpha.IntegTest |
![]() | github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2#IntegTest |
![]() | software.amazon.awscdk.integtests.alpha.IntegTest |
![]() | aws_cdk.integ_tests_alpha.IntegTest |
![]() | @aws-cdk/integ-tests-alpha ยป IntegTest |
Implements
IConstruct
, IDependable
A collection of test cases.
Each test case file should contain exactly one instance of this class.
Example
declare const app: App;
declare const stack: Stack;
declare const queue: sqs.Queue;
declare const fn: lambda.IFunction;
const integ = new IntegTest(app, 'Integ', {
testCases: [stack],
});
integ.assertions.invokeFunction({
functionName: fn.functionName,
invocationType: InvocationType.EVENT,
payload: JSON.stringify({ status: 'OK' }),
});
const message = integ.assertions.awsApiCall('SQS', 'receiveMessage', {
QueueUrl: queue.queueUrl,
WaitTimeSeconds: 20,
});
message.assertAtPath('Messages.0.Body', ExpectedResult.objectLike({
requestContext: {
condition: 'Success',
},
requestPayload: {
status: 'OK',
},
responseContext: {
statusCode: 200,
},
responsePayload: 'success',
}));
Initializer
new IntegTest(scope: Construct, id: string, props: IntegTestProps)
Parameters
- scope
Construct
- id
string
- props
Integ
Test Props
Construct Props
Name | Type | Description |
---|---|---|
test | Stack [] | List of test cases that make up this test. |
allow | string[] | List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test. |
assertion | Stack | Specify a stack to use for assertions. |
cdk | Cdk | Additional options to use for each CDK command. |
diff | boolean | Whether or not to include asset hashes in the diff Asset hashes can introduces a lot of unneccessary noise into tests, but there are some cases where asset hashes should be included. |
enable | boolean | Enable lookups for this test. |
hooks? | Hooks | Additional commands to run at predefined points in the test workflow. |
regions? | string[] | Limit deployment to these regions. |
stack | boolean | Run update workflow on this test case This should only be set to false to test scenarios that are not possible to test as part of the update workflow. |
testCases
Type:
Stack
[]
List of test cases that make up this test.
allowDestroy?
Type:
string[]
(optional, default: do not allow destruction of any resources on update)
List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test.
This list should only include resources that for this specific integration test we are sure will not cause errors or an outage if destroyed. For example, maybe we know that a new resource will be created first before the old resource is destroyed which prevents any outage.
e.g. ['AWS::IAM::Role']
assertionStack?
Type:
Stack
(optional, default: a stack is created for you)
Specify a stack to use for assertions.
cdkCommandOptions?
Type:
Cdk
(optional, default: runner default options)
Additional options to use for each CDK command.
diffAssets?
Type:
boolean
(optional, default: false)
Whether or not to include asset hashes in the diff Asset hashes can introduces a lot of unneccessary noise into tests, but there are some cases where asset hashes should be included.
For example any tests involving custom resources or bundling
enableLookups?
Type:
boolean
(optional, default: false)
Enable lookups for this test.
If lookups are enabled
then stackUpdateWorkflow
must be set to false.
Lookups should only be enabled when you are explicitly testing
lookups.
hooks?
Type:
Hooks
(optional, default: no hooks)
Additional commands to run at predefined points in the test workflow.
e.g. { postDeploy: ['yarn', 'test'] }
regions?
Type:
string[]
(optional, default: can run in any region)
Limit deployment to these regions.
stackUpdateWorkflow?
Type:
boolean
(optional, default: true)
Run update workflow on this test case This should only be set to false to test scenarios that are not possible to test as part of the update workflow.
Properties
Name | Type | Description |
---|---|---|
assertions | IDeploy | Make assertions on resources in this test case. |
node | Node | The tree node. |
assertions
Type:
IDeploy
Make assertions on resources in this test case.
node
Type:
Node
The tree node.
Methods
Name | Description |
---|---|
to | Returns a string representation of this construct. |
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.