You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just switched to Strikt and love it so far. However, I made the mistake of forgetting to validate values several times especially when tired or distracted because it reads naturally:
expectThat(person.isMarried())
instead of expectThat(person.isMarried()).isTrue()
so no actual validation is performed even though it reads like it would validate it so it's really easy to miss.
Similarly expectThat(person.age > 18) // instead of using .isGreaterThan(18)
etc.
Would it be possible to catch this flaw and throw an exception at runtime? Perhaps register the Assertion.Builder when creating it with expectThat(...) and capture whether any assertions were performed on it with a flag and throw an exception if it wasn't used by the end of the test.
An alternative approach would be to treat a missing validation as an implicit isTrue().
I would prefer the first approach of throwing an exception as that would nudge me towards writing more idiomatic tests but the second approach is better than skipping validations so either approach would be a large improvement.
The text was updated successfully, but these errors were encountered:
I just switched to Strikt and love it so far. However, I made the mistake of forgetting to validate values several times especially when tired or distracted because it reads naturally:
expectThat(person.isMarried())
instead of
expectThat(person.isMarried()).isTrue()
so no actual validation is performed even though it reads like it would validate it so it's really easy to miss.
Similarly
expectThat(person.age > 18)
// instead of using.isGreaterThan(18)
etc.
Would it be possible to catch this flaw and throw an exception at runtime? Perhaps register the Assertion.Builder when creating it with
expectThat(...)
and capture whether any assertions were performed on it with a flag and throw an exception if it wasn't used by the end of the test.An alternative approach would be to treat a missing validation as an implicit
isTrue()
.I would prefer the first approach of throwing an exception as that would nudge me towards writing more idiomatic tests but the second approach is better than skipping validations so either approach would be a large improvement.
The text was updated successfully, but these errors were encountered: