-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
A syntax that can allow grouping of assertions without compounding #805
Comments
|
As we discussed in the #790, it will be desirable with the shortened feature testing syntax. When you will not have the ability to easily see which assertion from the group has failed, making the stacktrace point to a correct assertion is very useful. |
How about the following:
where it does not matter where you place |
I agree with this. Not only for the shortened feature syntax, but in general. However, I think it would be great to brainstorm whether we can come up with a solution that does not require sacrificing fail-late behaviour. Because I think that’s one of atrium’s strengths: If multiple expectations fail, I don’t have to run my tests multiple times, I can see it straight away in the first run. So my question is: Can we find a solution that will be available for users that want to keep fail-late behaviour, as well? One possibility would be to have the main exception’s stack trace point to the first failing expectation, and add suppressed exceptions for every other failing expectation. This way, we would have a pointer for every failing expectation. But maybe we can even come up with a way for atrium to report the location of failed expectations. That way should support links in IDEs, though. |
As info, I intend to improve
That's something I had in mind but dismissed as we have this info in the stacktrace and I figured it will clutter the report. But I think it makes sense to revisit this idea for
As far as I can see, IntelliJ would turn it into a clickable link. The only problem here, we don't have the location and we would again need to resort to filepeek/compiler plugin or a different solution. Edit: We could also get the line number by creating a stacktrace. Slow as well but already better than filepeek Anyway, what I would like to know from you two. Do you think such a feature would be valuable also in other cases where we actually have the feature name? |
How would you find out which stack trace entry to take?
Yes, I can imagine this feature being useful in other scenarios as well. I am mainly thinking of larger tests where it’s not directly obvious where the expectation is located at. However, I could imagine that it would be better to have the information below the report (like we already have the stacktrace below the report) because it clutters the report less. Having said that, I also think that it’s worth considering my idea to use the suppressed expectations to report the other locations. If we filter the stack traces well, it might be a cheap but useful solution. |
E.g. by creating an exception when creating the feature extraction. The bad thing about it, we would need to create it also if the feature holds and creating exceptions is slow. Still better than filepeek which does this as well but file IO in addition. I would prefer to wait until the compile plugins is stable where such a feature should be fast.
if we put it below, then I would also go with the stacktrace since this is already familiar to the developer. However, we should use
Where we sneaked in |
Yeah, I got that, but which of the stack trace’s entries is the one to show to the user, if you want to select only one? Users might compose expectations out of other expectations, so a simple algorithm like ‘the first element that doesn’t belong to atrium’ will often not produce useful results. If we can’t get this right, we should prefer showing filtered stack traces, I think.
That is not my experience at all. Which kind of tooling are you referring to? IntelliJ prints suppressed exceptions (simply because the JVM prints them). Suppressed exceptions are, for example, quite common in Project Reactor.
I don’t like this idea because it is semantically wrong. A cause means ‘this exception only happened because of this other exception’, which is not true if multiple expectations fail. The semantic of suppressed exceptions, on the other hand, is ‘we would have shown you that other exception if we weren’t already processing this one’, which is exactly right for multiple failing expectations.
Interesting idea, however, I fear that it might irritate users a lot. The usual semantics of stack traces is to represent the stack. Listing multiple causing code lines is unintuitive. Also, we’d have the problem again that we need to identify ‘the one right stack trace element’ which will, as I wrote above, be difficult. |
@StragaSevera would one of these solutions address your use case? Or would you still want to have a way to make lambda blocks fail-fast? If yes, why? |
I remember that logging libraries where not showing it. But I was surprised to see lately, that they are now including it nowadays (which is good). So maybe my knowledge also outdated here
I did a quick check, it seems to be printed when using spek 🎉
Maybe a mistake on my part 🤷♂️ on the other hand, if the default does not show it, then it is not a solution IMO. |
That’s a bummer.
I’m not sure about this, since it is an additional reporting feature. Folks not seeing the suppressed exceptions can still see the stack trace of the main exception. However, I agree that we should try to find a better solution if we can. I just don’t think that it’s a show-stopper if we cannot find a better solution. |
Related to: #790
I think that the syntax where you pass a lambda to the
expect
function is useful, but there may be cases when you just want to group assertions without the need of compounding them - when it's perfectly OK to fail on the first failing assertion.I propose something like this:
Of course, the function name (
all
) is just the first name that I thought of.The text was updated successfully, but these errors were encountered: