You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2024/01/26 19:25:00 UTC
[jira] [Resolved] (HDDS-9951) Improve assertTrue assertions
[ https://issues.apache.org/jira/browse/HDDS-9951?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Attila Doroszlai resolved HDDS-9951.
------------------------------------
Fix Version/s: 1.5.0
Resolution: Done
There may be a few such assertions in some tests, but this task is largely complete. If you spot any of those while working on other tasks (e.g. HDDS-9956), please feel free to replace / improve.
Thanks a lot [~wangzhaohui], [~hemantk] for the contribution!
> Improve assertTrue assertions
> -----------------------------
>
> Key: HDDS-9951
> URL: https://issues.apache.org/jira/browse/HDDS-9951
> Project: Apache Ozone
> Issue Type: Improvement
> Components: test
> Reporter: Attila Doroszlai
> Assignee: Zhaohui Wang
> Priority: Major
> Fix For: 1.5.0
>
>
> Assertions in the form:
> {code}
> assertTrue(<string>.contains(...))
> assertFalse(<string>.contains(...))
> {code}
> do not provide any information about the actual value, if the assertion fails.
> {code}
> AssertionFailedError: expected: <true> but was: <false>
> {code}
> This can be improved by replacing them with:
> {code}
> import static org.assertj.core.api.Assertions.assertThat;
> assertThat(<string>).contains(...)
> assertThat(<string>).doesNotContain(...)
> {code}
> which gives us more info in the form:
> {code}
> AssertionError:
> Expecting:
> <"actual string">
> to contain:
> <"part">
> {code}
> Similarly, assertions about inequality relations, e.g.:
> {code}
> assertTrue(<x> > <y>);
> {code}
> can be replaced with:
> {code}
> assertThat(<x>).isGreaterThan(<y>);
> {code}
> And:
> {code}
> assertTrue(<x> instanceof <X>);
> {code}
> should be changed to
> {code}
> assertInstanceOf(<X>, <x>);
> {code}
> The goal of this task is to find and replace such {{assertTrue}} assertions.
> It will be divided into subtasks, by one or more modules, to avoid too big changes.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org