Skip to content

Conversation

sebsto
Copy link
Contributor

@sebsto sebsto commented Dec 21, 2024

This new example project show four testing strategies for Swift Lambda function

  • Unit testing the business logic (not specific to Swift Lambda)
  • Integration testing the handler method
  • Local invocation with the Swift Lambda Runtime
  • Local invocation with SAM

[IMPORTANT]
To allow testing the handler, I had to change visibility of a method in the Runtime project. This method is clearly marked for testing only, so it should not be a problem. Happy to read feedback and discuss however.

@sebsto sebsto added the semver/none No version bump required. label Dec 21, 2024
@sebsto sebsto requested review from 0xTim and adam-fowler December 21, 2024 17:45
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some queries around testing infrastructure

/// This interface is not part of the public API and must not be used by adopters.
/// It is declared public to allow users to unit test their handler.
/// This API is not part of semver versioning.
public static func __forTestsOnly(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we making this public if it can be visible with @testable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want it public, we might want to consider introducing a LambdaTesting target to keep it separate

Copy link
Contributor Author

@sebsto sebsto Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0xTim

You're correct, I was importing @testable import AWSLambdaRuntime but I needed AWSLambdaRuntimeCore

This is fixed now, this PR only touches files in the Examples directory. Thank you !

@sebsto sebsto force-pushed the sebsto/example_test branch from 61dda3a to 17cc50c Compare December 24, 2024 08:01
@sebsto
Copy link
Contributor Author

sebsto commented Dec 24, 2024

Note that the integration tests fail pending merging of #441

@sebsto sebsto force-pushed the sebsto/example_test branch from 821f2dd to 3cb188d Compare December 24, 2024 08:41
@sebsto sebsto merged commit cef85b9 into swift-server:main Dec 25, 2024
17 of 24 checks passed
@sebsto sebsto deleted the sebsto/example_test branch December 25, 2024 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants