geb.junit4.GebTest extends TestCase which is a JUnit 3 class. This means the test class can both be run as a JUnit 3 test and a JUnit 4 test. Eclipse seems to run it as a JUnit 4 test, and Gradle as a JUnit 3 test. That's why @RunWith doesn't get picked up when running with Gradle and execution fails because there is no parameterless constructor.
I filed a Geb issue for this some time ago and it has already been fixed for the upcoming 0.6 release of Geb. Meanwhile, if you want to write JUnit 4 tests, don't use geb.junit4.GebTest. I believe it's only a convenience class anyway. -- Peter Niederwieser Developer, Gradle http://www.gradle.org Trainer & Consultant, Gradleware http://www.gradleware.com Creator, Spock Framework http://spockframework.org netextzhwa wrote: > > Yes, it's here > > junit.framework.AssertionFailedError: Class DemoTest has no public > constructor TestCase(String name) or TestCase() > > junit.framework.AssertionFailedError: Class com.papyrus.qa.test.DemoTest > has no public constructor TestCase(String name) or TestCase() > at junit.framework.Assert.fail(Assert.java:47) > at junit.framework.TestSuite$1.runTest(TestSuite.java:97) > at junit.framework.TestCase.runBare(TestCase.java:134) > at junit.framework.TestResult$1.protect(TestResult.java:110) > at junit.framework.TestResult.runProtected(TestResult.java:128) > at junit.framework.TestResult.run(TestResult.java:113) > at junit.framework.TestCase.run(TestCase.java:124) > at junit.framework.TestSuite.runTest(TestSuite.java:232) > at junit.framework.TestSuite.run(TestSuite.java:227) > at > org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:51) > at > org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:63) > at > org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49) > 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:585) > at > org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) > at > org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) > at > org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) > at > org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:75) > at $Proxy4.processTestClass(Unknown Source) > at > org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:86) > 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:585) > at > org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) > at > org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) > at > org.gradle.messaging.remote.internal.MethodInvocationUnmarshallingDispatch.dispatch(MethodInvocationUnmarshallingDispatch.java:48) > at > org.gradle.messaging.dispatch.DiscardOnFailureDispatch.dispatch(DiscardOnFailureDispatch.java:31) > at > org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:129) > at > org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33) > at > org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:69) > at > org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:63) > at > java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675) > at java.lang.Thread.run(Thread.java:595) > 0.000 > > ________________________________ > From: Adam Murdoch [mailto:[email protected]] > Sent: Wednesday, March 30, 2011 12:38 PM > To: [email protected] > Subject: Re: [gradle-user] test run success in eclipse but fail with > gradle in command line? > > > On 30/03/2011, at 7:58 PM, netextzhwa wrote: > > Hi, > > I have two groovy(geb) junit tests and both of them run successfully in > eclipse. > > However, when I use gradle to run the test in command line, I get failure > message with one of them: > "junit.framework.AssertionFailedError: Class ParameterizedTest has no > public > constructor TestCase(String name) or TestCase()" > > Do you have the stack trace for these test failures? > > > -- > Adam Murdoch > Gradle Co-founder > http://www.gradle.org > VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting > http://www.gradleware.com > -- View this message in context: http://gradle.1045684.n5.nabble.com/test-run-success-in-eclipse-but-fail-with-gradle-in-command-line-tp4271042p4272095.html Sent from the gradle-user mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
