Skip to content
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

2020/03/18/places-where-you-really-need-to-use-assert-keyword-in-spock-assertions/ #7

Open
utterances-bot opened this issue Apr 19, 2020 · 2 comments

Comments

@utterances-bot
Copy link

@utterances-bot utterances-bot commented Apr 19, 2020

Places where you REALLY NEED to use 'assert' keyword in Spock assertions | Solid Soft

Make sure you know all the places where putting the 'assert' keyword in Spock is necessary to avoid false sense of security and tests which - effectively - do nothing.

https://blog.solidsoft.pl/2020/03/18/places-where-you-really-need-to-use-assert-keyword-in-spock-assertions/

@haridsv
Copy link

@haridsv haridsv commented Dec 15, 2021

Good article and subject, but you could convey the message better by saying where asserts are not required instead of indicating all the places you would need them, because as I can see from the article, you missed a few. The official documentation clearly states this:

Conditions are an essential ingredient of then blocks and expect blocks. Except for calls to void methods and expressions classified as interactions, all top-level expressions in these blocks are implicitly treated as conditions. To use conditions in other places, you need to designate them with Groovy’s assert keyword

This is why the condition in given: block, in method execution and in closure needed explicit assert. The other obvious places are if blocks, loops and catch blocks.

@szpak
Copy link
Owner

@szpak szpak commented Dec 26, 2021

Thanks @haridsv for taking time to made that constructive comment!

You are completely right. I've just added a new section covering the "other cases".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants