Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rfc: wing tests #5576

Closed
wants to merge 3 commits into from
Closed

rfc: wing tests #5576

wants to merge 3 commits into from

Conversation

tsuf239
Copy link
Collaborator

@tsuf239 tsuf239 commented Jan 30, 2024

fixes: #5540

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

@monadabot
Copy link
Contributor

monadabot commented Jan 30, 2024

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistence, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @eladb
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @skorfmann
Wing Playground @eladcon

#### Suggested:

We'll add another scope (and have two in total- outer scope, and inner scope) for the following structure:
//TODO: names
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd love to have some help here :)
@ekeren suggested test for outerScope and check/monitor for innerScope
I feel like it's not clear enough, but I'm not sure :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think check/monitor is intentionally a different concept, meant for testing live applications. This is RFC seems like it's aiming closer towards unit testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think check/monitor is intentionally a different concept, meant for testing live applications. This is RFC seems like it's aiming closer towards unit testing.

It is different concept but also very very similar to an inflight test especially when inflight tests do not run in isolation

I feel that in cases where things are very similar there is value in consolidating them into a single concept.

Copy link
Contributor

@eladb eladb Jan 30, 2024

Choose a reason for hiding this comment

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

I am not sure I agree. The fact that two concepts use similar mechanics doesn't mean they should be the same concept.

inflight test is also very similar to just a cloud.Function but they are different concepts.

There is also a consideration of design effort. I am not sure we have a reasonable way to model the idea of "an inflight test that doesn't run in isolation" (ideas welcome), some sometimes it's just easier to say "a test always runs in isolation and if you want something that doesn't run in isolation use a monitor".

Words are hard.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is my original idea for combining test (a wing program that contains both preflight and inflight code) and checks.

#5540 (comment)

@@ -0,0 +1,300 @@
---
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is an initial version, and I haven't filled some of the fields, @winglang/maintainers feel free to commit/ comment suggestions and solutions

4. [mocks](#4-mocks)
5. [spies](#5-spies)
6. [resource management optimization](#6-resource-management-optimization)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess 3-6 will be out of scope for this iteration... WDYT?

@tsuf239 tsuf239 changed the title repo(rfc): Wing Tests rfc rfc: Wing Tests rfc Jan 30, 2024
@tsuf239 tsuf239 changed the title rfc: Wing Tests rfc rfc: Wing Tests Jan 30, 2024
@tsuf239 tsuf239 changed the title rfc: Wing Tests rfc: wing tests Jan 30, 2024
Comment on lines +47 to +51
outerScope "bucket tests" {
/// preflight code only. Resources initialized here will be shared across innerScopes.
let bucket = new cloud.Bucket();

innerScope "bucket starts empty" {
Copy link
Contributor

Choose a reason for hiding this comment

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

When this topic has been brought up, usually there's mention of a preflight/inflight test concept, where the preflight test is the setup for the inflight tests. WDYT?

// breaking change, but like other declarations the phase can be inferred (preflight). imo explicit makes sense to me too.
test "bucket tests" {
  /// preflight code only. Resources initialized here will be shared across tests here
  let bucket = new cloud.Bucket();

  // explicitly inflight tests within the preflight test
  inflight test "bucket starts empty" {
  }
}

It's possible that users will be confused that it's a test within a test, although with good test output maybe it would be very intuitive.
If it does seem confusing, maybe we can be more explicit about it being a setup or group. Just some ideas:

suite "bucket tests" {
  /// preflight code only. Resources initialized here will be shared across tests here
  let bucket = new cloud.Bucket();
  
  preflight test "bucket as prop" {
  }

  // explicitly inflight tests within the preflight test
  inflight test "bucket starts empty" {
  }
}
test app "bucket tests" {
  /// preflight code only. Resources initialized here will be shared across tests here
  let bucket = new cloud.Bucket();
  
  preflight test "bucket as prop" {
  }

  // explicitly inflight tests within the preflight test
  inflight test "bucket starts empty" {
  }
}

Comment on lines +107 to +110
_global scope:_

- beforeEach, afterEach are called before or after each outerScope- before running the first innerScope, and after running the last one.
- beforeAll, afterAll are called before starting any of the innerScopes and after running them all.
Copy link
Contributor

Choose a reason for hiding this comment

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

There probably shouldn't be any testing-related functions in the global scope

Copy link

github-actions bot commented Feb 20, 2024

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days.
If you need help with the PR, do not hesitate to reach out in the winglang community discord at winglang.discord.com.
Feel free to re-open this PR when it is still relevant and ready to be worked on again.
Thanks!

@github-actions github-actions bot added the Stale label Feb 20, 2024
@tsuf239 tsuf239 removed the Stale label Feb 20, 2024
@tsuf239
Copy link
Collaborator Author

tsuf239 commented Jun 3, 2024

stale

@tsuf239 tsuf239 closed this Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

creating an rfc for testing
5 participants