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
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',
}));
# 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"
}))
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")));
// 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" }
}));
// 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
new IntegTest(scope: Construct, id: string, props: IntegTestProps)
IntegTest(scope: Construct, id: str, props: IntegTestProps)
new IntegTest(Construct scope, String id, IntegTestProps props)
new IntegTest(Construct scope, string id, IntegTestProps props)
NewIntegTest(Scope Construct, Id *string, Props IntegTestProps)
Construct Props
allowDeleteFailuresoptionalbooleanallow_delete_failuresoptionalboolallowDeleteFailuresoptionalBooleanAllowDeleteFailuresoptionalboolAllowDeleteFailuresoptional*bool= false#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#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#Default: a stack is created for you
cdkCommandOptionsoptionalCdkCommandscdk_command_optionsoptionalCdkCommandscdkCommandOptionsoptionalCdkCommandsCdkCommandOptionsoptionalCdkCommandsCdkCommandOptionsoptionalCdkCommands#Default: runner default options
diffAssetsoptionalbooleandiff_assetsoptionalbooldiffAssetsoptionalBooleanDiffAssetsoptionalboolDiffAssetsoptional*bool= false#For example any tests involving custom resources or bundling
enableLookupsoptionalbooleanenable_lookupsoptionalboolenableLookupsoptionalBooleanEnableLookupsoptionalboolEnableLookupsoptional*bool= false#If lookups are enabled then stackUpdateWorkflow must be set to false. Lookups should only be enabled when you are explicitly testing lookups.
Default: no hooks
e.g. { postDeploy: ['yarn', 'test'] }
providerLogLeveloptionalApplicationLogLevelprovider_log_leveloptionalApplicationLogLevelproviderLogLeveloptionalApplicationLogLevelProviderLogLeveloptionalApplicationLogLevelProviderLogLeveloptionalApplicationLogLevel= ApplicationLogLevel.FATAL#regionsoptionalstring[]regionsoptionaltyping.List[str]regionsoptionalList<String>Regionsoptionalstring[]Regionsoptional*[]*string#Default: can run in any region
stackUpdateWorkflowoptionalbooleanstack_update_workflowoptionalboolstackUpdateWorkflowoptionalBooleanStackUpdateWorkflowoptionalboolStackUpdateWorkflowoptional*bool= true#Properties
assertionsIDeployAssertassertionsIDeployAssertassertionsIDeployAssertAssertionsIDeployAssertAssertionsIDeployAssert#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#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#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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