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
Now that 1.4 is out, what's the status of feature testing new syntax? #790
Comments
Thanks for bringing that one up. I saw somewhere, that an internal Kotlin annotation (I don't remember the name, I think it was something with Builder in it) might help to trigger an experimental feature of the type inference system but I don't know if it would really help here. Besides, we are currently not yet able to provide an improved syntax as we first need to migrate from the old MPP plugin to the new MPP plugin (the old is no longer supported in Kotlin 1.4). See also #744. So I already agree, that we should update the Readme to reflect this. Nevertheless, I was lately again thinking about this issue, since also other people reached out to me that the syntax of feature assertions is not easy. Since you opened this issue, I am interested in your opinion. I plan to introduce a new function (name yet to be defined, in the following named
The reason why I have not done that so far (I thought about this many times) is that the reporting will look bad, as I don't know what feature was extracted:
Maybe this isn't as bad as I think because the stacktrace will still point to the correct line? Yet, this changes if one defines multiple features in an assertion group block as follows:
Because the stacktrace would point to
Therefore, I consider to add at least a counter so that one gets a little hint in addition
Not nearly as nice as
but maybe the improved readability of the code outweighs the poorer readability of the report? So, what I would like to know from you (and any other reading this):
|
Hmm, an interesting concept, I never thought about this aspect, I always thought that some reflection magic can extract the feature name from the lambda. Personally, I would be glad to have a readable syntax even at the cost of worse reporting - the indexing will give enough info for me to use this syntax. And I think the By the way, maybe there would be a way for a stack-trace to point to the correct line? For example, if I don't need the "compounding" behaviour, and I'm fine with the test stopping at the first failing assetion, I could use this: expect(person).all {
its { firstName }.toBe("Ilya")
its { lastName }.toBe("Fedorinov")
} , and this syntax (instead of just |
Thanks for your feedback. Although I like
In case you come up with a better suggestion, then please share it with us. |
Updated the README in the meantime. Keeping this issue open because I think it could be of interest for others to know the status quo and as a reminder that I want to look into it at some point. |
I think that it works fine for methods too - because we are testing its filter ;-) Seriously, though, the main benefit of this method is the length - only 3 symbols =-) I don't think there is a concise word that can replace it. |
Not entirely wrong that we are testings its filter 🙂 |
Thank you, will wait for it eagerly! =-) And what do you think about the |
@StragaSevera I think this idea needs its own ticket. I agree with the feature you want to see (jumping directly to the first failing assertion from the stack trace) but disagree with the solution you propose. So let’s discuss in a separate ticket, shall we? |
Ok, will open it =-) |
I am closing this issue as I opened a new one for |
@StragaSevera did you have chance to try out |
The Readme says:
"We are sorry that the syntax is not yet the nicest one. We admit that one has to get used to it first and that is a pity. Yet, it is due to many Kotlin Bugs standing in the way -- we hope we can provide a better API once Kotlin 1.4 is out (the new type inference respectively)."
Now that 1.4 is out, what's the status of an improved syntax? If it is still not possible, then maybe the Readme should be improved?..
The text was updated successfully, but these errors were encountered: