Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Niranjan Jayakar committed Sep 29, 2021
1 parent cdaf349 commit fd367e2
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions text/0031-integ-testing.md
@@ -1,6 +1,6 @@
# Integration testing for CDK apps

* **Original Author(s):**: [@nija-at](https://github.com/nija-at)
* **Original Author(s)**: [@nija-at](https://github.com/nija-at)
* **Tracking Issue**: [#31](https://github.com/aws/aws-cdk-rfcs/issues/31)
* **API Bar Raiser**: @{BAR_RAISER_USER}

Expand Down Expand Up @@ -73,7 +73,7 @@ new AwsAssertion(repoTest, 'MessageReceived', {

const testResult = repoTest.run();
if (testResult.failures > 0) {
// test runner should fail the test
// notify the test runner to fail
}
```

Expand Down Expand Up @@ -101,6 +101,19 @@ new InvokeLambda(test, 'Invoke', {
});
```

The `AwsAssertion` also allows multiple calls to be chained. The following calls Amazon S3 `GetObject` API
based on the value returned from an Amazon DynamoDB `GetItem` call.

```ts
const response = new AwsAssertion(test, 'GetItem', {
request: AwsAssertionCall.DynamoDB.getItem({ ... }),
});

new AwsAssertion(test, 'GetObject', {
request: AwsAssertionCall.S3.getObject({ bucket: ..., key: response.Item.Payload }),
});
```

When canned assertions are insufficient, `apptest` also provides a mechanism to write custom assertions.
Custom assertions are simply AWS Lambda Functions, and in the CDK, these are any construct that implements `IFunction`.

Expand Down Expand Up @@ -129,7 +142,10 @@ To invoke this assertion, you can simply use the `invokeLambda()` API -

```ts
const hdrAssertion = new StdHeaderAssertion(...);
test.invokeLambda(hdrAssertion);

new InvokeLambda(test, {
lambda: hdrAssertion,
});
```

> RFC Note: See [Appendix A](#appendix-a---assertions) for details on the underlying design.
Expand Down Expand Up @@ -319,7 +335,7 @@ With such changes, it is best to re-run all your tests in full (as is the defaul
to ensure that all of the new changes do not have any unintended impact to your application.

Rarely, the AWS CDK will change the synthesized template in backwards compatible ways, such as,
changing the order of properties, or setting a property to its default.
changing the order of properties, or setting a property to its default.
As stated previously, it is still safer to run all tests with invalidated snapshots.

[assets]: https://docs.aws.amazon.com/cdk/latest/guide/assets.html
Expand Down Expand Up @@ -519,4 +535,4 @@ the apptest test execution mechanism will likely have to re-implement features t
already present in most popular testing frameworks today.

The proposal does not produce the test report in any known format, and this is going to lead
to poor integration with test reporting tools that support well known test reporting formats.
to poor integration with test reporting tools that support well known test reporting formats.

0 comments on commit fd367e2

Please sign in to comment.