You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Brett Porter (JIRA)" <ji...@codehaus.org> on 2007/01/21 23:02:21 UTC
[jira] Moved: (SUREFIRE-114) Surefire plugin throws
NoSuchMethodException when errors occur during TestSetup decorator
[ http://jira.codehaus.org/browse/SUREFIRE-114?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brett Porter moved MSUREFIRE-119 to SUREFIRE-114:
-------------------------------------------------
Affects Version/s: (was: 2.0 (2.2 plugin))
2.0 (2.2 plugin)
Fix Version/s: (was: 2.3)
2.3
Key: SUREFIRE-114 (was: MSUREFIRE-119)
Project: Maven Surefire (was: Maven 2.x Surefire Plugin)
> Surefire plugin throws NoSuchMethodException when errors occur during TestSetup decorator
> -----------------------------------------------------------------------------------------
>
> Key: SUREFIRE-114
> URL: http://jira.codehaus.org/browse/SUREFIRE-114
> Project: Maven Surefire
> Issue Type: Bug
> Affects Versions: 2.0 (2.2 plugin)
> 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