You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Kenney Westerhof (JIRA)" <ji...@codehaus.org> on 2006/12/19 04:24:41 UTC

[jira] Closed: (MSUREFIRE-119) Surefire plugin throws NoSuchMethodException when errors occur during TestSetup decorator

     [ http://jira.codehaus.org/browse/MSUREFIRE-119?page=all ]

Kenney Westerhof closed MSUREFIRE-119.
--------------------------------------

      Assignee: Kenney Westerhof
    Resolution: Fixed

Fixed in revision 488512.

> Surefire plugin throws NoSuchMethodException when errors occur during TestSetup decorator
> -----------------------------------------------------------------------------------------
>
>                 Key: MSUREFIRE-119
>                 URL: http://jira.codehaus.org/browse/MSUREFIRE-119
>             Project: Maven 2.x Surefire Plugin
>          Issue Type: Bug
>    Affects Versions: 2.2
>            Reporter: Dan Fabulich
>         Assigned To: Kenney Westerhof
>             Fix For: 2.3
>
>         Attachments: setup-bug.zip
>
>
> I've included an example maven project, "setup-bug.zip".  It was created by doing "mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=setup-bug" and then modifying AppTest.java to use a "TestSetup" decorator.  
> Normally JUnit runs your setUp()/tearDown() methods once for every test method... so if you've got a TestCase with methods testFoo and testBar, JUnit will normally run like this: setUp testFoo tearDown setUp testBar tearDown.  You can use a TestSetup decorator to run your setUp function just once for the class: TestSetup.setUp testFoo testBar TestSetup.tearDown.
> In the example given, the test's setup method throws a RuntimeException (as tests sometimes do).  Instead of handling this gracefully, Maven Surefire throws a NoSuchMethodException as it attempts to call .getName() on the TestSetup object (which isn't guaranteed to have a name).
> Running com.mycompany.app.AppTest
> org.apache.maven.surefire.booter.SurefireExecutionException: com.mycompany.app.AppTest; nested exception is java.lang.reflect.UndeclaredThrowableException: null; nested exception is org.apache.maven.surefire.testset.TestSetFailedException: com.mycompany.app.AppTest; nested exception is java.lang.reflect.UndeclaredThrowableException: null
> org.apache.maven.surefire.testset.TestSetFailedException: com.mycompany.app.AppTest; nested exception is java.lang.reflect.UndeclaredThrowableException: null
> java.lang.reflect.UndeclaredThrowableException
> 	at $Proxy0.addError(Unknown Source)
> 	at junit.framework.TestResult.addError(TestResult.java:36)
> 	at junit.framework.TestResult.runProtected(TestResult.java:133)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:210)
> 	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:135)
> 	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:122)
> 	at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:324)
> 	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:225)
> 	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:747)
> Caused by: java.lang.NoSuchMethodException: com.mycompany.app.AppTest$AppTestSetup.getName()
> 	at java.lang.Class.getMethod(Class.java:986)
> 	at org.apache.maven.surefire.junit.TestListenerInvocationHandler.getStackTraceWriter(TestListenerInvocationHandler.java:171)
> 	at org.apache.maven.surefire.junit.TestListenerInvocationHandler.handleAddError(TestListenerInvocationHandler.java:160)
> 	at org.apache.maven.surefire.junit.TestListenerInvocationHandler.invoke(TestListenerInvocationHandler.java:134)
> 	... 18 more
> [INFO] ------------------------------------------------------------------------
> [ERROR] BUILD FAILURE
> [INFO] ------------------------------------------------------------------------
> You can workaround this by hardcoding a public String getName() method on the TestSetup object and ensuring that it's public.

-- 
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