TestCase

class aws_cdk.cloud_assembly_schema.TestCase(*, allow_destroy=None, cdk_command_options=None, diff_assets=None, hooks=None, regions=None, stack_update_workflow=None, stacks, assertion_stack=None)

Bases: aws_cdk.cloud_assembly_schema.TestOptions

Represents an integration test case.

Parameters
  • allow_destroy (Optional[Sequence[str]]) – 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’] Default: - do not allow destruction of any resources on update

  • cdk_command_options (Optional[CdkCommands]) – Additional options to use for each CDK command. Default: - runner default options

  • diff_assets (Optional[bool]) – 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 Default: false

  • hooks (Optional[Hooks]) – Additional commands to run at predefined points in the test workflow. e.g. { postDeploy: [‘yarn’, ‘test’] } Default: - no hooks

  • regions (Optional[Sequence[str]]) – Limit deployment to these regions. Default: - can run in any region

  • stack_update_workflow (Optional[bool]) – 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. Default: true

  • stacks (Sequence[str]) – Stacks that should be tested as part of this test case The stackNames will be passed as args to the cdk commands so dependent stacks will be automatically deployed unless exclusively is passed.

  • assertion_stack (Optional[str]) – The name of the stack that contains assertions. Default: - no assertion stack

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.cloud_assembly_schema as cloud_assembly_schema

test_case = cloud_assembly_schema.TestCase(
    stacks=["stacks"],

    # the properties below are optional
    allow_destroy=["allowDestroy"],
    assertion_stack="assertionStack",
    cdk_command_options=cloud_assembly_schema.CdkCommands(
        deploy=cloud_assembly_schema.DeployCommand(
            args=cloud_assembly_schema.DeployOptions(
                all=False,
                app="app",
                asset_metadata=False,
                ca_bundle_path="caBundlePath",
                change_set_name="changeSetName",
                ci=False,
                color=False,
                context={
                    "context_key": "context"
                },
                debug=False,
                ec2_creds=False,
                exclusively=False,
                execute=False,
                force=False,
                ignore_errors=False,
                json=False,
                lookups=False,
                notices=False,
                notification_arns=["notificationArns"],
                output="output",
                outputs_file="outputsFile",
                parameters={
                    "parameters_key": "parameters"
                },
                path_metadata=False,
                profile="profile",
                proxy="proxy",
                require_approval=cloud_assembly_schema.RequireApproval.NEVER,
                reuse_assets=["reuseAssets"],
                role_arn="roleArn",
                rollback=False,
                stacks=["stacks"],
                staging=False,
                strict=False,
                toolkit_stack_name="toolkitStackName",
                trace=False,
                use_previous_parameters=False,
                verbose=False,
                version_reporting=False
            ),
            enabled=False,
            expected_message="expectedMessage",
            expect_error=False
        ),
        destroy=cloud_assembly_schema.DestroyCommand(
            args=cloud_assembly_schema.DestroyOptions(
                all=False,
                app="app",
                asset_metadata=False,
                ca_bundle_path="caBundlePath",
                color=False,
                context={
                    "context_key": "context"
                },
                debug=False,
                ec2_creds=False,
                exclusively=False,
                force=False,
                ignore_errors=False,
                json=False,
                lookups=False,
                notices=False,
                output="output",
                path_metadata=False,
                profile="profile",
                proxy="proxy",
                role_arn="roleArn",
                stacks=["stacks"],
                staging=False,
                strict=False,
                trace=False,
                verbose=False,
                version_reporting=False
            ),
            enabled=False,
            expected_message="expectedMessage",
            expect_error=False
        )
    ),
    diff_assets=False,
    hooks=cloud_assembly_schema.Hooks(
        post_deploy=["postDeploy"],
        post_destroy=["postDestroy"],
        pre_deploy=["preDeploy"],
        pre_destroy=["preDestroy"]
    ),
    regions=["regions"],
    stack_update_workflow=False
)

Attributes

allow_destroy

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’]

Default
  • do not allow destruction of any resources on update

Return type

Optional[List[str]]

assertion_stack

The name of the stack that contains assertions.

Default
  • no assertion stack

Return type

Optional[str]

cdk_command_options

Additional options to use for each CDK command.

Default
  • runner default options

Return type

Optional[CdkCommands]

diff_assets

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

Default

false

Return type

Optional[bool]

hooks

Additional commands to run at predefined points in the test workflow.

e.g. { postDeploy: [‘yarn’, ‘test’] }

Default
  • no hooks

Return type

Optional[Hooks]

regions

Limit deployment to these regions.

Default
  • can run in any region

Return type

Optional[List[str]]

stack_update_workflow

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.

Default

true

Return type

Optional[bool]

stacks

Stacks that should be tested as part of this test case The stackNames will be passed as args to the cdk commands so dependent stacks will be automatically deployed unless exclusively is passed.

Return type

List[str]