-
Couldn't load subscription status.
- Fork 1.4k
Add fail-fast assertion to ZIO test #6923
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
Conversation
|
@reibitto Does it meet your requirements? |
8a03283 to
fa3bb38
Compare
|
Maybe there are better names
|
|
Love this functionality and how simple the implementation is. I wonder if there is a way to not have to call a different operator at all. What if |
|
@adamgfraser Thanks for the great suggestion! I succeeded to eliminate |
|
@guersam That's great! Does this work with assertions composed with |
|
@adamgfraser Yup, added it as a test case. |
da39558 to
e523446
Compare
| spec = test("test") { | ||
| for { | ||
| _ <- ref.update(_ + 1) | ||
| _ <- assertTrue(true) && assertTrue(false) |
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'm more wondering if we do assertTrue(somethingFalse) && assertTrue(someThingElseFalse) do we get both failures in the error message? I think this is the case where we don't want to fail fast.
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.
Good point. Revised the test case.
e523446 to
5110f2d
Compare
d81c58a to
4822f9e
Compare
|
|
||
| implicit def liftTestResultToZIO[R, E](result: TestResult)(implicit trace: Trace): ZIO[R, E, TestResult] = | ||
| if (result.isSuccess) | ||
| ZIO.succeedNow(result) |
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'm not 100% sure if I correctly understood the purpose of suceedNow here.
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.
It's just like succeed but it is private to zio and doesn't store the argument in a thunk (i.e., it doesn't use a by-name parameter). So it's faster, but you have to be careful where you use it.
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.
@kitlangton thanks for clarifying. What about tracing in this case? I wonder if it's okay that the implicit trace argument is ignored in the happy path.
|
Rebased upon latest changes. |
f1f8d63 to
7349a83
Compare
|
@kitlangton Could you take a look this one? |
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.
Looks great! Awesome work @guersam.
* Add fail-fast assertion to ZIO test (zio#5181) * Lift TestResult to ZIO automatically * Test composed TestResult's ZIO lift * minor consistency * Improve TestResult lift test case * Fix tests in Scala 3 * Avoid unnecessary trace * Make TestResult.Exit final
It enables fail-fast assertion with helpful error reports in large test scenarios such as integration tests.
Closes #5181