|
please do this on the surefire-testng branch (which will be brought back to trunk eventually now that it is not experimental, but isn't yet). It is completely refactored and a much more achievable task there. RunListener (the JUnit 4.0 equivalent of TestListener) is a class, not an interface, so I can't create a proxy for it. I can't really move forward until they fix it, or unless it's okay for me to have a compile-time dependency on JUnit 4.0. Attached is a first-pass at the code (testing using a modified version of JUnit 4.0 where I changed RunListener to an interface).
John Didion made changes - 06/Mar/06 03:40 PM
I'll take a look. It's not required that you don't use JUnit at all (see the testng provider for example). However, that is used to guarantee classloader separation which is still desirable. IF there is another alternative, that would be fine.
Brett Porter made changes - 24/Mar/06 05:23 PM
Brett Porter made changes - 27/Mar/06 06:07 PM
Jason van Zyl made changes - 30/May/06 08:50 PM
Is there anything I can do to make this happen? I'm needing this ASAP... I've got about 4000 junit 4 tests to automate. Is there anything I can do to speed this along or is there beta code out there someplace that I can use in the interim? I modifed JUnitTestSet to use JUnitCore from junit4 to run The problem is now that surefire's reporting classes expect information Additionally surefire's POJO approach collides with junit4. Anyone looking for a temporary measure try out http://www.unto.net/wiki/Maven_JUnit4_plugin
Bernd made changes - 13/Aug/06 04:02 AM
Looks like I could successfully connect maven reporting with JUnitCore, the problems mentioned above are not existing. Some basic test run now and mvn site creates to surefire html report. But now I run into MSUREFIREREP-26, I will have a look at that... With the attached patch I can run some exemplary junit4 tests. I will use it to run tests from a real project later. The patch has the following features:
Bernd made changes - 16/Aug/06 03:29 PM
I tried to download surefire-junit4.zip. When I tried to run "mvn install" from unziped surefire-junit4 directory. I got the following exceptions: [INFO] Scanning for projects... GroupId: org.apache.maven.surefire Reason: Unable to download the artifact from any repository org.apache.maven.surefire:surefire-providers:pom:2.0-SNAPSHOT from the specified remote repositories: [INFO] ------------------------------------------------------------------------ at org.codehaus.classworlds.Launcher.main(Launcher.java:375) org.apache.maven.surefire:surefire-providers:pom:2.0-SNAPSHOT from the specified remote repositories: at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepo org.apache.maven.surefire:surefire-providers:pom:2.0-SNAPSHOT from the specified remote repositories: at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(De Could you please tell me which Maven2 Repository I should add to make it work? Thanks a lot! Jian Hi, I found that I can use the apache.snapshots repository at: But, I encountered the following up problem: C:\TrinityPrj\maven2\surefire-junit4\src\main\java\org\apache\maven\surefire\jun C:\TrinityPrj\maven2\surefire-junit4\src\main\java\org\apache\maven\surefire\jun [INFO] ------------------------------------------------------------------------ Any suggestion to work-around it would be really appreciated! Thanks, Jian Jian, as a first step, please have a look at There is some information about how to apply a patch Does that help? Bernd
fabrizio giustina made changes - 31/Aug/06 08:23 AM
fabrizio giustina made changes - 03/Sep/06 03:00 AM
As you know, testing is an unavoidable part of any software projects to really harness the quality of software products, since JUnit 4.x is out and its being a de facto standard in testing, I think surefire plugin issues should be solved as soon as possible to really support JUnit 4.x using Maven 2. As near as I can tell, none of the previous patches work:
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 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: Hope that helps everyone. Please add a comment if you run into any problems with these patches. Enjoy!
Karl M. Davis made changes - 06/Oct/06 01:27 PM
Karl M. Davis made changes - 06/Oct/06 01:28 PM
Oh, I should also mention that you will not be able to run both JUnit3 and JUnit4 tests alongside each other with this patch. Two things would need to be done to make that happen:
If one of the regular committers took care of those two things, I think my patches could be included in the next version. In the meantime, they're a better solution for JUnit4 testing with Maven2 than the separate plugin at http://www.unto.net/wiki/Maven_JUnit4_plugin This patch is an alternative to the other two I posted. Instead of adding JUnit4 support as a new provider, it patches the existing JUnit3 provider so that it now properly supports the "suite()" method.
Karl M. Davis made changes - 09/Oct/06 02:28 PM
Do the snapshots take into account these patches? I'm debating between junit4 & testNG and it looks like I don't have a choice but to use testNG Hi, this is in reply to Bernd's comment from 29/Jul/06 01:49 PM: > The problem is now that surefire's reporting classes expect information I'm not sure what information surefire's reporting classes need. However wiedkla Hi, here a sample output: klaus@jsesoft:/projects/junit4/xmllistener> klaus@jsesoft:/projects/junit4/xmllistener> mvn package ------------------------------------------------------- Results : [INFO] [jar:jar] Is anything "official" being worked on for this at the moment? It seems to be blocking many people from migrating to JUnit 4. I too am considering using TestNG now instead. I'm able to build and install Karl's 2nd method....however, I have no idea how to configure maven to use this. I currently have the snapshot surefire installed in my local repository....how do I tell maven to use this rather than the surefire it's bundled with? THANKS! <<how do I tell maven to use this rather than the surefire it's bundled with?>> I can't say for certain but I think Maven will try to use the snapshot version in your local repository automatically. It's been a bit since I had to install this myself, so my memory's a bit foggy. If I had my project compiling right now I'd test that for you... but I don't. Give it a try and let us know if it works just having it installed. If not, I'll get my stuff compiling again on Monday and give you instructions on how to get Maven to use the surefire snapshot. Best of luck! Karl, You're correct in that it will pick it up appropriately, but I did have to rebuild the maven-surefire-plugin identifying the snapshot release as the dependency in order for it to work. This works great, thanks for the patch! I took Karls code and added it to the current surefire trunk. I moved the junit4 code to its own surefire-junit4 provider. The old junit3 provider is not touched and it is still the default. Patch attached... patch to the surefire trunk
Tom Huybrechts made changes - 06/Jan/07 11:13 AM
previous patch was missing a pom...
Tom Huybrechts made changes - 06/Jan/07 11:43 AM
Jason van Zyl made changes - 06/Jan/07 12:07 PM
Patches applied. Final form taken from Tom. Thanks.
Jason van Zyl made changes - 06/Jan/07 12:09 PM
Is it possible to run execute testNG, junit4, and junit3 tests together in the same project? |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
It seems like a good first step would be adding a JUnit4Battery to surefire. I'll volunteer to take a first shot at this, basing it on the JUnitBattery.