-
Notifications
You must be signed in to change notification settings - Fork 181
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
rfc: wing tests #5576
Conversation
Thanks for opening this pull request! 🎉
|
#### Suggested: | ||
|
||
We'll add another scope (and have two in total- outer scope, and inner scope) for the following structure: | ||
//TODO: names |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 test
s 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -0,0 +1,300 @@ | |||
--- |
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
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?
outerScope "bucket tests" { | ||
/// preflight code only. Resources initialized here will be shared across innerScopes. | ||
let bucket = new cloud.Bucket(); | ||
|
||
innerScope "bucket starts empty" { |
There was a problem hiding this comment.
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" {
}
}
_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. |
There was a problem hiding this comment.
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
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. |
stale |
fixes: #5540
Checklist
pr/e2e-full
label if this feature requires end-to-end testingBy submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.