[ 
https://issues.apache.org/jira/browse/HDDS-9956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Attila Doroszlai updated HDDS-9956:
-----------------------------------
    Description: 
Tests of the following form can be simplified:

{code}
try {
  <some action>
  fail()
} catch (Exception e) {
  assertTrue(e instanceof <SpecificException>)
  <further assertions>
}
{code}

to:

{code}
<SpecificException> e = assertThrows(<SpecificException>.class,
    () -> <some action>);
<further assertions>
{code}

It can be divided into subtasks, by one or more modules, to avoid too big 
changes.

  was:
Tests of the following form can be simplified:

{code}
try {
  <some action>
  fail()
} catch (Exception e) {
  assertTrue(e instanceof <SpecificException>)
  <further assertions>
}
{code}

to:

{code}
<SpecificException> e = assertThrows(<SpecificException>.class,
    () -> <some action>);
<further assertions>
{code}


> Simplify tests using assertThrows
> ---------------------------------
>
>                 Key: HDDS-9956
>                 URL: https://issues.apache.org/jira/browse/HDDS-9956
>             Project: Apache Ozone
>          Issue Type: Improvement
>          Components: test
>            Reporter: Attila Doroszlai
>            Priority: Major
>
> Tests of the following form can be simplified:
> {code}
> try {
>   <some action>
>   fail()
> } catch (Exception e) {
>   assertTrue(e instanceof <SpecificException>)
>   <further assertions>
> }
> {code}
> to:
> {code}
> <SpecificException> e = assertThrows(<SpecificException>.class,
>     () -> <some action>);
> <further assertions>
> {code}
> It can 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to