You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Jeff Holoman (JIRA)" <ji...@apache.org> on 2014/12/28 01:27:15 UTC
[jira] [Comment Edited] (KAFKA-1782) Junit3 Misusage
[ https://issues.apache.org/jira/browse/KAFKA-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14259533#comment-14259533 ]
Jeff Holoman edited comment on KAFKA-1782 at 12/28/14 12:26 AM:
----------------------------------------------------------------
I did a check through the tests looking for things like '(expected' and 'JUnit3Suite'. The good news is I don't think there are any cases that tests are passing where they shouldn't be, and I didn't find any instances against trunk where a test would pass silently due features that aren't implemented in JUnit 3. There is one exception (HighwatermarkPersistenceTest) where the teardown is not being called due to use of the @After notation. There is also a bit of "mixing" where both JUnitSuite and the older junit.framework.Assert (vs. org.junit.Assert) is being used.
So how would we like to proceed here? It probably makes sense to have a standard set of libraries that are imported in each test.
Are we ok with using scalatest features like intercept[] rather than @Test(expected..) ?. If we remove all the references to JUnit3Suite there is some cleanup work (mostly in setup/teardown and adding annotations).
was (Author: jholoman):
I did a check through the tests looking for things like '(expected' and 'JUnit3Suite'. The good news is I don't think there are any cases that tests are passing where they shouldn't be, and I didn't find any instances against trunk where a test would pass silently due features that aren't implemented in JUnit 3. There is one exception (HighwatermarkPersistenceTest) where the teardown is not being called due to use of the @After notation. There is also a bit of "mixing" where both JUnitSuite and the older junit.framework.Assert (vs. org.junit.Assert) is being used.
So how would we like to proceed here? It probably makes sense to have a standard set of libraries that are imported in each test.
Are we ok with using scalatest features like intercept[] rather than @Test(expected..) ?. If we remove all the references to JUnit3Suite there is some cleanup work (mostly in setup/teardwon and adding annotations).
> Junit3 Misusage
> ---------------
>
> Key: KAFKA-1782
> URL: https://issues.apache.org/jira/browse/KAFKA-1782
> Project: Kafka
> Issue Type: Bug
> Reporter: Guozhang Wang
> Assignee: Jeff Holoman
> Labels: newbie
> Fix For: 0.8.2
>
>
> 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)