-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
report all expectations within an expectation-group block #1342
Comments
What do you think of creating a property/function on Expect instead of adding parameters all over the place? |
I guess this issue duplicates #724 |
#724 is related but not the same. there are already functions to modify the behaviour on an Expect level (all experimental): but we don't provide it at arbitrary places. I think we still need an option on the expectation function level because otherwise you will incorporate a side effect in your expectation function which might change the behaviour of other expectation functions by accident. what I could imagine is to provide a way to modify report options within an expectation group. then one would kind of redefine the default options within that group and would still have the possibility to change it per function. |
I do not follow you here. There's an option to configure the way the group is printed: all assertions, failing only. What is the difference between the option at expect level vs an option at "all" parameter? There's no difference, except a new parameter in "all" method would be harder to use and harder to discover |
Maybe some more context:
Now imagine you would define the following:
I would imagine that the With the above this would mean, that suddenly every expectation function which follows a call to For the same reason, I am hesitant to add an option for an expectation group, something like:
I am also not yet convinced this is really something one wants to define individually per expectation group. I think it is enough, if one can define this at the I think we are safe to add it already on an expectation function level where it influences only this very specific expectation. Taking the example in the description. the |
Feature-level things (e.g. nested expect that changes subject) are not much different from RootExpect. |
fun Expect<T>.between(t1: T, t2: T) =
.and {
report = { showSummary() } // side effect, changes the behaviour for all subsequent expectation functions within this expectation group
toBeLessThan(t1)
toBeGreaterThan(2)
} What if the actions on |
I agree in terms of creating expectations but not in terms of reporting. Do you think you will ever want to define:
instead of:
That's exactly how I would implement it "// side effect, changes the behaviour for all subsequent expectation functions within this expectation group" |
I would prefer a structured way. For instance: expect(x) {
showSummary() // for both address and age
address { ... }
age { ... }
}
expect(x) {
address {
showSummary() // just here
...
}
age { ... }
} Frankly speaking, I would refrain from syntax like expect(x)
.report { showSummary() } // show summary by default
.address { ... }
.age { ... } It is not significantly different from expect(x)
.address { ... }
.or
.age { ... }
.and
.age { ... }
.and
.not
.age { ... }
.please
.no |
good point, I basically do the same, switch to group syntax as soon as I state more than one expectation. We already have (the experimental) API:
which I don't want to move into the group as changing e.g. the Reporter in the middle will only cause trouble. I.e. this should only be doable on the RootExpect before the first expectation was created. So my example was wrong, it would more likely look as follows:
We could change it to:
but that would mean that e.g. changing the representation of the subject is a tiny bit more verbose than now:
vs. current
but we would have only one approach which IMO is better. WDYT? |
Platform (all, jvm, js): all
Extension (none, kotlin 1.3): none
Code related feature
I want to provide a
between
function which reports lower and upper bound as soon as one of them fails. Yet, I don't want to activate report all expectations by default (i.e. change reporting). I kind of want that the between expectation is considered as one block.In Atrium terms, I want an easy way to define a summary group
Would then show in reporting:
TODO:
report: ReportOptions.() -> Unit
as parameter in every place where we currently have assertionCreators:for instance, to
and
(and group/expectGrouped, see Add soft assertions for verifying unrelated subjects #1330) s so that one can define between as:The text was updated successfully, but these errors were encountered: