You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2022/03/30 02:57:00 UTC

[jira] [Commented] (SPARK-38694) Simplify Java UT code with Junit `assertThrows`

    [ https://issues.apache.org/jira/browse/SPARK-38694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17514413#comment-17514413 ] 

Apache Spark commented on SPARK-38694:
--------------------------------------

User 'LuciferYang' has created a pull request for this issue:
https://github.com/apache/spark/pull/36008

> Simplify Java UT code with Junit `assertThrows`
> -----------------------------------------------
>
>                 Key: SPARK-38694
>                 URL: https://issues.apache.org/jira/browse/SPARK-38694
>             Project: Spark
>          Issue Type: Improvement
>          Components: Tests
>    Affects Versions: 3.4.0
>            Reporter: Yang Jie
>            Priority: Minor
>
> There are some code patterns in Java UTs:
> {code:java}
>  @Test
>   public void testAuthReplay() throws Exception {
>     try {
>       doSomeOperation();
>       fail("Should have failed");
>     } catch (Exception e) {
>       assertTrue(checkException(e));
>     }
>   }
> {code}
> or 
>  
> {code:java}
> @Test(expected = SomeException.class)
>   public void testAuthReplay() throws Exception {
>     try {
>       doSomeOperation();
>       fail("Should have failed");
>     } catch (Exception e) {
>       assertTrue(checkException(e));
>       throw e;
>     }
>   } {code}
> we can use Junit assertThrows to simplify the similar patterns
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org