On Sun, Nov 12, 2006 at 11:08:21PM +1100, J. Matthew Pryor spake thus:
*snip*
> I am porting from maven 1 to maven 2, and we had begun using junit 4.1 
> by using the JUnit4TestAdapter like so:
*snip*
> This worked fine for maven 1 and since I didn't know any better, was 
> ported over to maven 2, where it *MOSTLY* works.
> 
> I say mostly, because there are 2 out of about 80 classes don't get any 
> tests detected in them i.e.
*snip*
> From reading around, it looks like I am between a rock & a hard place 
> because http://jira.codehaus.org/browse/MSUREFIRE-131 would imply the 
> approach above shouldn't work (well it doesn't seem to all the time) but 
> http://jira.codehaus.org/browse/MSUREFIRE-84 would imply that native 
> junit 4 support is not baked properly either.
> 
> I'd rather not go to a temporary solution like 
> http://www.unto.net/wiki/Maven_JUnit4_plugin if I don't have to.
> 
> Any insights, work-arounds of corrections would be greatly appreciated

We've had good results using a slightly modified version of the patches
attached to SUREFIRE-31 by Karl M. Davis:

    http://jira.codehaus.org/browse/SUREFIRE-31#action_76833

We basically made an internal version of the surefire plugin (based on a
patched version of the svn code from 2006-10-11) for projects that use
JUnit-4.x.

As for your 2 out of 80 classes not having their JUnit-4.x tests
detected, this may be due to the behavior of the default surefire
plugin: it attempts to run as tests anything that looks like a junit-3.x
test, a TestNG test, or a non-framework-related unit test (methods named
test*()). It may be that your unit tests are not being run by the
provider you think they are. A simple way to test this would be to add
(to one of your classes where no unit tests are detected) methods that
print something recognizable to stderr:

    * a JUnit-4.x style @Before method

    * a JUnit-4.x style @Test annotated method named doFoo() [that is,
       /not/ named testFoo()]

    * a method named testJunk()

I suspect that you'll see the output from testJunk() only. More to the
point, using a patched version of the surefire plugin is the only
solution I've seen that supports JUnit-4.x completely. In this case,
"completely" means "completely for my purposes" as I've not tested every
JUnit-4.x feature using our patched version, but I have tested these
behaviors:

    * Exceptions in @BeforeClass, @Before, @AfterClass, and @After
      methods are detected and reported (they fail the tests)

    * Methods annotated with @Test, and /only/ those methods, are
      treated as unit test methods (regardless of the method name)

HTH,
-Al

-- 
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
::
Alan D. Salewski
Software Developer
Health Market Science, Inc.
:: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: :: ::
:: 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to