Class TestCase
Represents an integration test case.
Inheritance
Namespace: Amazon.CDK.CloudAssemblySchema
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class TestCase : Object, ITestCase, ITestOptions
Syntax (vb)
Public Class TestCase
Inherits Object
Implements ITestCase, ITestOptions
Remarks
ExampleMetadata: fixture=_generated
Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.Cloud_assembly_schema;
var testCase = new TestCase {
Stacks = new [] { "stacks" },
// the properties below are optional
AllowDestroy = new [] { "allowDestroy" },
AssertionStack = "assertionStack",
AssertionStackName = "assertionStackName",
CdkCommandOptions = new CdkCommands {
Deploy = new DeployCommand {
Args = new DeployOptions {
All = false,
App = "app",
AssetMetadata = false,
CaBundlePath = "caBundlePath",
ChangeSetName = "changeSetName",
Ci = false,
Color = false,
Concurrency = 123,
Context = new Dictionary<string, string> {
{ "contextKey", "context" }
},
Debug = false,
Ec2Creds = false,
Exclusively = false,
Execute = false,
Force = false,
IgnoreErrors = false,
Json = false,
Lookups = false,
Notices = false,
NotificationArns = new [] { "notificationArns" },
Output = "output",
OutputsFile = "outputsFile",
Parameters = new Dictionary<string, string> {
{ "parametersKey", "parameters" }
},
PathMetadata = false,
Profile = "profile",
Proxy = "proxy",
RequireApproval = RequireApproval.NEVER,
ReuseAssets = new [] { "reuseAssets" },
RoleArn = "roleArn",
Rollback = false,
Stacks = new [] { "stacks" },
Staging = false,
Strict = false,
ToolkitStackName = "toolkitStackName",
Trace = false,
UsePreviousParameters = false,
Verbose = false,
VersionReporting = false
},
Enabled = false,
ExpectedMessage = "expectedMessage",
ExpectError = false
},
Destroy = new DestroyCommand {
Args = new DestroyOptions {
All = false,
App = "app",
AssetMetadata = false,
CaBundlePath = "caBundlePath",
Color = false,
Context = new Dictionary<string, string> {
{ "contextKey", "context" }
},
Debug = false,
Ec2Creds = false,
Exclusively = false,
Force = false,
IgnoreErrors = false,
Json = false,
Lookups = false,
Notices = false,
Output = "output",
PathMetadata = false,
Profile = "profile",
Proxy = "proxy",
RoleArn = "roleArn",
Stacks = new [] { "stacks" },
Staging = false,
Strict = false,
Trace = false,
Verbose = false,
VersionReporting = false
},
Enabled = false,
ExpectedMessage = "expectedMessage",
ExpectError = false
}
},
DiffAssets = false,
Hooks = new Hooks {
PostDeploy = new [] { "postDeploy" },
PostDestroy = new [] { "postDestroy" },
PreDeploy = new [] { "preDeploy" },
PreDestroy = new [] { "preDestroy" }
},
Regions = new [] { "regions" },
StackUpdateWorkflow = false
};
Synopsis
Constructors
Test |
Properties
Allow |
List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test. |
Assertion |
The node id of the stack that contains assertions. |
Assertion |
The name of the stack that contains assertions. |
Cdk |
Additional options to use for each CDK command. |
Diff |
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. |
Hooks | Additional commands to run at predefined points in the test workflow. |
Regions | Limit deployment to these regions. |
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 |
Stack |
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. |
Constructors
TestCase()
public TestCase()
Properties
AllowDestroy
List of CloudFormation resource types in this stack that can be destroyed as part of an update without failing the test.
public string[] AllowDestroy { get; set; }
Property Value
System.
Remarks
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
AssertionStack
The node id of the stack that contains assertions.
public string AssertionStack { get; set; }
Property Value
System.
Remarks
This is the value that can be used to deploy the stack with the CDK CLI
Default: - no assertion stack
AssertionStackName
The name of the stack that contains assertions.
public string AssertionStackName { get; set; }
Property Value
System.
Remarks
Default: - no assertion stack
CdkCommandOptions
Additional options to use for each CDK command.
public ICdkCommands CdkCommandOptions { get; set; }
Property Value
Remarks
Default: - runner default options
DiffAssets
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.
public Nullable<bool> DiffAssets { get; set; }
Property Value
System.
Remarks
For example any tests involving custom resources or bundling
Default: false
Hooks
Additional commands to run at predefined points in the test workflow.
public IHooks Hooks { get; set; }
Property Value
Remarks
e.g. { postDeploy: ['yarn', 'test'] }
Default: - no hooks
Regions
Limit deployment to these regions.
public string[] Regions { get; set; }
Property Value
System.
Remarks
Default: - can run in any region
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.
public string[] Stacks { get; set; }
Property Value
System.
StackUpdateWorkflow
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.
public Nullable<bool> StackUpdateWorkflow { get; set; }
Property Value
System.
Remarks
Default: true