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 run into numerous tests which make assumptions for specific types of objects by casting to that type. Before a lot of those casts, an assertTrue is used to validate that the assumption is correct.
This assertion however is far less verbose than the class cast exception that would occur without the assertion. Namely, when the assertion fails it will state that false is not true. As opposed to class XXX cannot be casted to ZZZ, without the assertion. In some cases, such as very sporadic test failures, the actual type of the object can give vital clues for the nature of the fail.
It would be great if a warning issue is shown on the line, explaining why such assertions are not a good practice in tests.
The text was updated successfully, but these errors were encountered:
I run into numerous tests which make assumptions for specific types of objects by casting to that type. Before a lot of those casts, an
assertTrue
is used to validate that the assumption is correct.This assertion however is far less verbose than the class cast exception that would occur without the assertion. Namely, when the assertion fails it will state that false is not true. As opposed to class XXX cannot be casted to ZZZ, without the assertion. In some cases, such as very sporadic test failures, the actual type of the object can give vital clues for the nature of the fail.
It would be great if a warning issue is shown on the line, explaining why such assertions are not a good practice in tests.
The text was updated successfully, but these errors were encountered: