sqoop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boglarka Egyed (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (SQOOP-3090) Normalize test cases where expect an exception
Date Tue, 03 Jan 2017 13:37:58 GMT

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

Boglarka Egyed edited comment on SQOOP-3090 at 1/3/17 1:37 PM:
---------------------------------------------------------------

Hi [~maugli],

I would run the tests with JUnit4 and the following JUnit Rule would be added to verify if
a specific exception has been thrown:

{code:java}
@Rule
public ExpectedException exception = ExpectedException.none();
{code}

In this way the logic described above could be replaced with this simpler one:

{code:java}
Exception expectedException = new Exception();
exception.expect(sameInstance(expectedException));
<do something>
{code}

Based on my research around 14 test classes would be affected:
* TestAvroExport
* TestCodecMap
* TestConnFactory
* TestExportUpdate
* TestExportUsingProcedure
* TestHCatalogBasic
* TestHiveImport
* TestLobFile
* TestParquetExport
* TextSplitterHadoopConfIntegrationTest
* TestSqoopOptions
* TestTableDefWriter
* TestTargetDir
* TestTextSplitter

These could be divided into subgroups to reduce the impact of the change on a test set. What
do you think?

I would like to start to work on this as soon as possible, even today.

Thanks for your thoughts in advance!

Cheers,
Bogi







was (Author: boglarkaegyed):
Hi [~maugli],

I would run the tests with JUnit4 and the following JUnit Rule would be added to verify if
a specific exception has been thrown:

{code:java}
@Rule
public ExpectedException exception = ExpectedException.none();
{code}

In this way the logic described above could be replaced with this simpler one:

{code:java}
Exception expectedException = new Exception();
exception.expect(sameInstance(expectedException));
<do something>
{code}

Based on my research around 14 test classes would be effected:
* TestAvroExport
* TestCodecMap
* TestConnFactory
* TestExportUpdate
* TestExportUsingProcedure
* TestHCatalogBasic
* TestHiveImport
* TestLobFile
* TestParquetExport
* TextSplitterHadoopConfIntegrationTest
* TestSqoopOptions
* TestTableDefWriter
* TestTargetDir
* TestTextSplitter

These could be divided into subgroups to reduce the impact of the change on a test set. What
do you think?

I would like to start to work on this as soon as possible, even today.

Thanks for your thoughts in advance!

Cheers,
Bogi






> Normalize test cases where expect an exception
> ----------------------------------------------
>
>                 Key: SQOOP-3090
>                 URL: https://issues.apache.org/jira/browse/SQOOP-3090
>             Project: Sqoop
>          Issue Type: Improvement
>    Affects Versions: 1.4.6
>            Reporter: Boglarka Egyed
>            Assignee: Boglarka Egyed
>            Priority: Minor
>
> Many test cases uses the following logic to test if an exception has been thrown:
> {code:java}
> try {
>       <do something>
>       fail("Expected exception");
>     } catch (someException e) {
>       // expected
>     }
>   }
> {code}
> This form is not self-explanatory enough and could be replaced by a one line ExpectedException
check which would be more clean.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message