Replies: 7 comments 11 replies
-
I like it! And don't see a reason not to support it |
Beta Was this translation helpful? Give feedback.
-
I feel like this would open the door to unhealthy tests, unless the test is created within the class itself of course.
|
Beta Was this translation helpful? Give feedback.
-
🤔 Except this encourages not testing the contract, and testing internal implementation, which is generally not what you want. I'm on the fence here. |
Beta Was this translation helpful? Give feedback.
-
It will make it impossible to write multi-platform tests. Right now tests are multi clouds (multi platforms), when we add a test that tests internal implementation, we put a weird constraints on someone that will want to extend the API for another platform. Think about |
Beta Was this translation helpful? Give feedback.
-
Just to suggest another alternative of this with a form of scoping keyword. This keyword allows you to say that the test is scoped to this class, given it access to private values in that class.
The syntax could support multiple values even
Would make it a very active choice in the test if it should be allowed to touch private properties. |
Beta Was this translation helpful? Give feedback.
-
Perhaps we could create an "expose" marker in the tests indicating which private method the test can access. Something like this
Or perhaps use "expose" to indicate the class and expose all methods, but the important thing would be to indicate this exposure for the test.
|
Beta Was this translation helpful? Give feedback.
-
How about we allow a test to access private members only if it's defined in the same file as the class. (Basically treat it as |
Beta Was this translation helpful? Give feedback.
-
When writing tests it's very common to need to inspect the internal state of an object.
In most programming languages, it is a huge hassle because internal state is usually protected by the type system though access modifiers (
private
orprotected
). Developers work around this by making these APIs public, extracting them to separate functions or other creative means.Since Wing has testing as first-class citizen, we can decide that code written within a
test
block in Wing will have access to private members as if they were marked asinternal
(i.e. within the same library).And the world will be a better place.
Beta Was this translation helpful? Give feedback.
All reactions