Skip to content
v2.275.0

Experimental

@aws-cdk/integ-tests-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.

IntegTest ​

A collection of test cases.

Each test case file should contain exactly one instance of this class.

Example ​

ts
declare const app: App;
declare const stack: Stack;
declare const sm: IStateMachine;

const testCase = new IntegTest(app, 'IntegTest', {
  testCases: [stack],
});

// Start an execution
const start = testCase.assertions.awsApiCall('StepFunctions', 'startExecution', {
  stateMachineArn: sm.stateMachineArn,
});

// describe the results of the execution
const describe = testCase.assertions.awsApiCall('StepFunctions', 'describeExecution', {
  executionArn: start.getAttString('executionArn'),
});

// assert the results
describe.expect(ExpectedResult.objectLike({
  status: 'SUCCEEDED',
}));
python
# app: App
# stack: Stack
# sm: IStateMachine


test_case = IntegTest(app, "IntegTest",
    test_cases=[stack]
)

# Start an execution
start = test_case.assertions.aws_api_call("StepFunctions", "startExecution", {
    "state_machine_arn": sm.state_machine_arn
})

# describe the results of the execution
describe = test_case.assertions.aws_api_call("StepFunctions", "describeExecution", {
    "execution_arn": start.get_att_string("executionArn")
})

# assert the results
describe.expect(ExpectedResult.object_like({
    "status": "SUCCEEDED"
}))
java
App app;
Stack stack;
IStateMachine sm;


IntegTest testCase = IntegTest.Builder.create(app, "IntegTest")
        .testCases(List.of(stack))
        .build();

// Start an execution
IApiCall start = testCase.assertions.awsApiCall("StepFunctions", "startExecution", Map.of(
        "stateMachineArn", sm.getStateMachineArn()));

// describe the results of the execution
IApiCall describe = testCase.assertions.awsApiCall("StepFunctions", "describeExecution", Map.of(
        "executionArn", start.getAttString("executionArn")));

// assert the results
describe.expect(ExpectedResult.objectLike(Map.of(
        "status", "SUCCEEDED")));
csharp
// Install: dotnet add package Amazon.CDK.IntegTests.Alpha
App app;
Stack stack;
IStateMachine sm;


var testCase = new IntegTest(app, "IntegTest", new IntegTestProps {
    TestCases = new [] { stack }
});

// Start an execution
var start = testCase.Assertions.AwsApiCall("StepFunctions", "startExecution", new Dictionary<string, string> {
    { "stateMachineArn", sm.StateMachineArn }
});

// describe the results of the execution
var describe = testCase.Assertions.AwsApiCall("StepFunctions", "describeExecution", new Dictionary<string, string> {
    { "executionArn", start.GetAttString("executionArn") }
});

// assert the results
describe.Expect(ExpectedResult.ObjectLike(new Dictionary<string, object> {
    { "status", "SUCCEEDED" }
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdkintegtestsalpha/v2
var app App
var stack Stack
var sm IStateMachine


testCase := awscdkintegtestsalpha.NewIntegTest(app, jsii.String("IntegTest"), &IntegTestProps{
	TestCases: []Stack{
		stack,
	},
})

// Start an execution
start := testCase.Assertions.AwsApiCall(jsii.String("StepFunctions"), jsii.String("startExecution"), map[string]*string{
	"stateMachineArn": sm.stateMachineArn,
})

// describe the results of the execution
describe := testCase.Assertions.AwsApiCall(jsii.String("StepFunctions"), jsii.String("describeExecution"), map[string]*string{
	"executionArn": start.getAttString(jsii.String("executionArn")),
})

// assert the results
describe.Expect(awscdkintegtestsalpha.ExpectedResult_ObjectLike(map[string]interface{}{
	"status": jsii.String("SUCCEEDED"),
}))

Initializer ​

ts
new IntegTest(scope: Construct, id: string, props: IntegTestProps)
python
IntegTest(scope: Construct, id: str, props: IntegTestProps)
java
new IntegTest(Construct scope, String id, IntegTestProps props)
csharp
new IntegTest(Construct scope, string id, IntegTestProps props)
go
NewIntegTest(Scope Construct, Id *string, Props IntegTestProps)

Construct Props ​

allowDeleteFailuresoptionalbooleanallow_delete_failuresoptionalboolallowDeleteFailuresoptionalBooleanAllowDeleteFailuresoptionalboolAllowDeleteFailuresoptional*bool= false#
Whether to allow resources that fail to delete during a stack update.

When false, the test will fail if CloudFormation skips deleting a resource during a stack update. When true, only a warning is printed.

allowDestroyoptionalstring[]allow_destroyoptionaltyping.List[str]allowDestroyoptionalList<String>AllowDestroyoptionalstring[]AllowDestroyoptional*[]*string#
List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test.

Default: do not allow destruction of any resources on update

notes

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

assertionStackoptionalStackassertion_stackoptionalStackassertionStackoptionalStackAssertionStackoptionalStackAssertionStackoptionalStack#
Specify a stack to use for assertions.

Default: a stack is created for you

cdkCommandOptionsoptionalCdkCommandscdk_command_optionsoptionalCdkCommandscdkCommandOptionsoptionalCdkCommandsCdkCommandOptionsoptionalCdkCommandsCdkCommandOptionsoptionalCdkCommands#
Additional options to use for each CDK command.

Default: runner default options

diffAssetsoptionalbooleandiff_assetsoptionalbooldiffAssetsoptionalBooleanDiffAssetsoptionalboolDiffAssetsoptional*bool= 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

enableLookupsoptionalbooleanenable_lookupsoptionalboolenableLookupsoptionalBooleanEnableLookupsoptionalboolEnableLookupsoptional*bool= 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.

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

Default: no hooks

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

providerLogLeveloptionalApplicationLogLevelprovider_log_leveloptionalApplicationLogLevelproviderLogLeveloptionalApplicationLogLevelProviderLogLeveloptionalApplicationLogLevelProviderLogLeveloptionalApplicationLogLevel= ApplicationLogLevel.FATAL#
The log level of the provider lambda function.
regionsoptionalstring[]regionsoptionaltyping.List[str]regionsoptionalList<String>Regionsoptionalstring[]Regionsoptional*[]*string#
Limit deployment to these regions.

Default: can run in any region

stackUpdateWorkflowoptionalbooleanstack_update_workflowoptionalboolstackUpdateWorkflowoptionalBooleanStackUpdateWorkflowoptionalboolStackUpdateWorkflowoptional*bool= 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.
testCasesStack[]test_casestyping.List[Stack]testCasesList<Stack>TestCasesStack[]TestCases*[]Stackrequired#
List of test cases that make up this test.

Properties ​

assertionsIDeployAssertassertionsIDeployAssertassertionsIDeployAssertAssertionsIDeployAssertAssertionsIDeployAssert#
Make assertions on resources in this test case.
nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.

Methods ​

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.

1 parameter · returns

Parameters

  • mixinsmixinsmixinsmixinsMixins — The mixins to apply.

Returns: This construct for chaining