[ http://jira.codehaus.org/browse/SUREFIRE-31?page=comments#action_76833 ] 
            
Karl M. Davis commented on SUREFIRE-31:
---------------------------------------

As near as I can tell, none of the previous patches work:
 - surefire-junit4.zip: Does not compile and after spending a bit looking into 
it, I don't think it can be made to easily.
 - SUREFIRE-31-surefire-trunk.patch & SUREFIRE-31-maven-surefire-plugin.patch: 
These can be made to compile (if you comment out some stuff) but they're 
basically a hack (no offense intended) and don't seem to report results 
correctly.

Both of these patches are based on the JUnit3.x provider, which is the wrong 
approach, I believe.  The code is pretty complicated: involves using proxies 
(dynamically generated classes, I believe) and a pretty poorly-defined 
interface.  I'm sure there was a reason for writing them this way (perhaps was 
the standard approach for JUnit3 providers) but it isn't necessary for JUnit4 
and should be abandoned.

I have created two new patch files which are working perfectly for me.  I 
created the new JUnit4 provider from scratch, (very) loosely based off of the 
TestNG provider's approach.  To apply these patches, check out the 
maven-surefire-plugin project from 
https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-surefire-plugin and 
apply the SUREFIRE31_karl_maven-surefire-plugin.patch file to it (on Windows: 
right-click the checked-out folder, go to the TortoiseSVN menu, and select 
Apply Patch).  Then, check out the surefire/surefire-providers/surefire-junit 
project from 
https://svn.apache.org/repos/asf/maven/surefire/trunk/surefire-providers/surefire-junit
 and apply the SUREFIRE31_karl_surefire_surefire-providers_surefire-junit.patch 
file to it.  Then, in the root of each project, run "mvn clean install 
-Dmaven.test.skip=true" to install the surefire updates to your local Maven 
repository.  After that, you should be good to go.

Oh, you'll need to make sure that no older versions of JUnit (3.x) are included 
in your POM-- even as transitive dependencies.  If one of your other 
dependencies is bringing JUnit 3 along for the ride, add an exclusion to your 
POM, like I had to do in the following case:
    </dependency>
        <dependency>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jpox-maven-plugin</artifactId>
                <version>1.0.3-SNAPSHOT</version>
                <exclusions>
                        <exclusion>
                                <groupId>junit</groupId>
                                <artifactId>junit</artifactId>
                        </exclusion>
                </exclusions>
                <scope>provided</scope>
        </dependency>
    <dependency>

Hope that helps everyone.  Please add a comment if you run into any problems 
with these patches.

Enjoy!


> support junit 4.0
> -----------------
>
>                 Key: SUREFIRE-31
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-31
>             Project: surefire
>          Issue Type: Improvement
>          Components: Junit 4.x support
>            Reporter: John Didion
>             Fix For: 2.1
>
>         Attachments: SUREFIRE-31-maven-surefire-plugin.patch, 
> SUREFIRE-31-surefire-trunk.patch, surefire-junit4.zip
>
>
> I know this is a pretty sizable task. I just wanted to get it in the system 
> now that 4.0 has officially been released. Hopefully this will generate some 
> discussion about how 4.0 will be handled - mainly if it will require a 
> completely seperate implemenation of surefire (keeping the same API so it can 
> easily be used by the maven plugin), or if use of 4.0 will be made a 
> configurable option of the current surefire.
> Here's some additional features I'd like to see:
> 1. Ability to categorize tests. Unfortunately, 4.0 doesn't include an 
> @Category annotation, or make category a parameter of @Test. However, the 
> filtering mechanism provided by 4.0 is sufficent to support categories given 
> the presense of such an annotation. I recommend putting the @Category 
> annotation in a seperate module (surefire-annotations?) and build support for 
> it into surefire. Hopefully the junit guys could be convinced to incorporate 
> it in a later version.
> 2. Similarly, support repeated tests via an @Repeated annotation. I'm not 
> sure how easy this would be to do external to junit.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to