-
Notifications
You must be signed in to change notification settings - Fork 627
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
Add expect block to skip tests #3596
Conversation
I like it. Tried to come up with some naming alternatives but it's hard.. @mickeelm you're pretty good at spitting out names, any thoughts on this one? 😄 |
Btw would this be compatible with having a second variant?: inline fun <reified T> TestScope.expect(thunk: () -> T) = runCatching {
thunk()
}.mapError {
ExpectFailureException
}.getOrThrow()
val user = expect { createUser() } |
Yeah that's better. |
Might make the intent a bit more obvious? |
precondition or condition or prereq are other alternatives.
…On Wed, Aug 2, 2023, 7:20 AM Emil Kantis ***@***.***> wrote:
- assumeSuccess {}
- assumeSuccessful {}
- expectSuccess {}
Might make the intent a bit more obvious?
—
Reply to this email directly, view it on GitHub
<#3596 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFVSGWEJDEQQEHTOP3AILLXTJAZTANCNFSM6AAAAAA24RQJRI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
I'll try to live up to that introduction :) I like I think Some other suggestions:
|
I think I prefer |
I like onlyIf or runIf |
I can't get two variants to work, it always wants to resolve to the Boolean one. So we might need another name for the one that returns a value. |
*/ | ||
object ExpectFailureException : Exception() | ||
|
||
fun TestScope.runIf(thunk: () -> Boolean) { |
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 could make this runIf(condition: Boolean)
, then we can have rhe one taking a function return T
Closes #3582
This adds the ability to do
expect { someboolean() }
in a test block, which, if false, marks the test as skipped.Happy to rename "expect" to something else: