You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Philip Harvey (JIRA)" <ji...@apache.org> on 2013/01/08 07:20:12 UTC

[jira] [Commented] (QPID-3025) Upgrade Java test framework to JUnit 4

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

Philip Harvey commented on QPID-3025:
-------------------------------------

I've paused this upgrade while the config refactoring work is in progress on the config refactoring branch for QPID-4390 (https://svn.apache.org/repos/asf/qpid/branches/java-broker-config-qpid-4390/).

I looked into how we could use JUnit 4's Categories runner to replace our test filtering logic, but have run into problems. In case anyone's interested, here is a summary:

The vanilla usage of the org.junit.experimental.categories.Categories runner is to write a dedicated suite like so:
{noformat}
@RunWith(Categories.class)
@IncludeCategory(SlowTests.class)
@SuiteClasses( { A.class, B.class })
// Note that Categories is a kind of Suite
public static class SlowTestSuite {
}
{noformat}

It's obviously undesireable to enumerate all the test classes. The most common way round this is to use the ClasspathSuite library (http://johanneslink.net/projects/cpsuite.jsp), as described on Stack Overflow [here|http://stackoverflow.com/questions/2176570/how-to-run-all-tests-belonging-to-a-certain-category-in-junit-4/2176791#2176791]

Unfortunately ClasspathSuite is GPL 2.0 licensed, so cannot be used by Qpid.

The only alternative therefore seems to be that we write our own ClassPathSuite equivalent, i.e. something that searches the classpath for all the classes with @Test annotations. This is not particularly hard but it is frustrating that we need reinvent the wheel in this manner. A good starting point is the example code [here|http://linsolas.free.fr/wordpress/index.php/2011/02/how-to-categorize-junit-tests-with-maven/].
                
> Upgrade Java test framework to JUnit 4
> --------------------------------------
>
>                 Key: QPID-3025
>                 URL: https://issues.apache.org/jira/browse/QPID-3025
>             Project: Qpid
>          Issue Type: Improvement
>          Components: Java Tests
>            Reporter: Andrew Kennedy
>            Assignee: Philip Harvey
>            Priority: Minor
>         Attachments: 0001-QPID-3025-WIP-junit4-upgrade.patch
>
>
> We use JUnit 3.8 currently, and should move to using a more recent version. JUnit 4.4 includes support for annotations and other useful test features that will allow us to control our unit and system tests and test profiles better and easier. This update must still be able to run the existing 3.8 tests, and must also preserve the current exclusion mechanism (profile.excludes property) but should also support all JUnit 4 features. This is possible by transferring some functionality from QpidTestCase to a custom JUnit runner class, and annotating QpidTestCase to use this new test runner.
> See also QPID-2639 which updated the QpidTestCase and modified all other test cases to inherit from it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org