-
Couldn't load subscription status.
- Fork 1.4k
Fixed #1691 - ZIO Test: Make failure TestAspect
#1741
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
|
|
||
| test.foldCauseM( | ||
| _.untraced match { | ||
| case Cause.Fail(TestFailure.Runtime(Traced(e, _))) if p.run(e).isSuccess => |
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.
untraced removes all inner Traced so this shouldn't be needed?
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.
from what I tested I had to get rid of it before I could match things.
| ZIO.succeed(TestSuccess.Succeeded(BoolAlgebra.unit)) | ||
|
|
||
| case other => { | ||
| println(s"other = $other") |
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.
You can remove this one
|
@ghostdogpr We are going to change the signature of this to take an |
|
@adamgfraser ah ok that makes sense 👍 |
| /** | ||
| * Makes a new assertion that verifies a TestFailure matches a given failure | ||
| */ | ||
| final def testFails[E](failure: E): Assertion[TestFailure[E]] = { |
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.
maybe failsWith? @adamgfraser wdyt?
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 we can simplify this. I am reviewing now.
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.
Almost there! Just a few changes
| else BoolAlgebra.failure(AssertionValue(self, actual)) | ||
| } | ||
|
|
||
| final def isInstance[A](reference: A): Assertion[Any] = |
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 would take this out and use isSubType in your test.
| } | ||
|
|
||
| /** | ||
| * An aspect that makes a test succeed if it fails for any cause. |
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 we need to update this a bit because it makes a test that failed for any reason into a success, it doesn't have to be because the test failed with a Cause. It could have just failed with an AssertionFailure. Also clarify that it makes a previously successful test into a failure.
| val failure: PerTest[Nothing, Any, Nothing, Any, Unit, Unit] = failure(Assertion.anything) | ||
|
|
||
| /** | ||
| * An aspect that makes a test succeed if it fails for a given cause. |
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.
Same as above.
| def perTest[R >: Nothing <: Any, E >: Nothing <: E0, S >: Unit <: Unit]( | ||
| test: ZIO[R, TestFailure[E], TestSuccess[S]] | ||
| ): ZIO[R, TestFailure[E], TestSuccess[S]] = { | ||
| def fail(value: TestFailure[E]) = ZIO.fail( |
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.
Maybe you can inline these definitions into test.foldM since they are each only used once?
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! Will merge when it goes green.
No description provided.