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

ASF GitHub Bot commented on KAFKA-1782:
---------------------------------------

GitHub user ewencp opened a pull request:

    https://github.com/apache/kafka/pull/140

    KAFKA-1782: Follow up - add missing @Test annotations.

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ewencp/kafka kafka-1782-followup

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/140.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #140
    
----
commit 1dcaf39d489c26b564186fbe8d1bddb987f38e3e
Author: Ewen Cheslack-Postava <m...@ewencp.org>
Date:   2015-08-14T22:43:56Z

    KAFKA-1782: Follow up - add missing @Test annotations.

----


> Junit3 Misusage
> ---------------
>
>                 Key: KAFKA-1782
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1782
>             Project: Kafka
>          Issue Type: Bug
>            Reporter: Guozhang Wang
>            Assignee: Alexander Pakulov
>              Labels: newbie
>             Fix For: 0.8.3
>
>         Attachments: KAFKA-1782.patch, KAFKA-1782.patch, 
> KAFKA-1782_2015-06-18_11:52:49.patch, KAFKA-1782_2015-07-15_16:57:44.patch, 
> KAFKA-1782_2015-07-16_11:50:05.patch, KAFKA-1782_2015-07-16_11:56:11.patch
>
>
> This is found while I was working on KAFKA-1580: in many of our cases where 
> we explicitly extend from junit3suite (e.g. ProducerFailureHandlingTest), we 
> are actually misusing a bunch of features that only exist in Junit4, such as 
> (expected=classOf). For example, the following code
> {code}
> import org.scalatest.junit.JUnit3Suite
> import org.junit.Test
> import java.io.IOException
> class MiscTest extends JUnit3Suite {
>   @Test (expected = classOf[IOException])
>   def testSendOffset() {
>   }
> }
> {code}
> will actually pass even though IOException was not thrown since this 
> annotation is not supported in Junit3. Whereas
> {code}
> import org.junit._
> import java.io.IOException
> class MiscTest extends JUnit3Suite {
>   @Test (expected = classOf[IOException])
>   def testSendOffset() {
>   }
> }
> {code}
> or
> {code}
> import org.scalatest.junit.JUnitSuite
> import org.junit._
> import java.io.IOException
> class MiscTest extends JUnit3Suite {
>   @Test (expected = classOf[IOException])
>   def testSendOffset() {
>   }
> }
> {code}
> or
> {code}
> import org.junit._
> import java.io.IOException
> class MiscTest {
>   @Test (expected = classOf[IOException])
>   def testSendOffset() {
>   }
> }
> {code}
> will fail.
> I would propose to not rely on Junit annotations other than @Test itself but 
> use scala unit test annotations instead, for example:
> {code}
> import org.junit._
> import java.io.IOException
> class MiscTest {
>   @Test
>   def testSendOffset() {
>     intercept[IOException] {
>       //nothing
>     }
>   }
> }
> {code}
> will fail with a clearer stacktrace.



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

Reply via email to