Groovy Unit test not running with CliBuilder

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Groovy Unit test not running with CliBuilder

MikeM
I have the following unit test:

class AcmeTest extends GroovyTestCase {
  void setUp() {
    def cl = new CliBuilder()
    println "Setup done"
  }
  void testInit() {
    println "testInit done"
  }
}

This runs fine when run using the Groovy commandline.

When running as a unit test in Eclipse I get the following:

java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at AcmeTest.class$(AcmeTest.groovy)
        at AcmeTest.$get$$class$groovy$util$CliBuilder(AcmeTest.groovy)
        at AcmeTest.setUp(AcmeTest.groovy:3)
        at junit.framework.TestCase.runBare(TestCase.java:132)
        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.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 19 more

Using   Groovy-Eclipse Feature    2.1.0.xx-20101007-1100-e36-RC2    org.codehaus.groovy.eclipse.feature.feature.group
Reply | Threaded
Open this post in threaded view
|

Re: Groovy Unit test not running with CliBuilder

Andrew Eisenberg
You are getting this because Groovy-Eclipse does not include the
commons-cli jar on the build path by default.  To fix this:

* go to your project right click -> Properties -> Java Build Path ->
Libraries.
* Click Add External Jars...
* Browse to your Eclipse/plugins/org.codehaus.groovy_1.7.5xx-???/lib directory
* Choose commons-cli-1.2.jar

On Wed, Oct 20, 2010 at 12:00 AM, MikeM <[hidden email]> wrote:

>
> I have the following unit test:
>
> class AcmeTest extends GroovyTestCase {
>  void setUp() {
>    def cl = new CliBuilder()
>    println "Setup done"
>  }
>  void testInit() {
>    println "testInit done"
>  }
> }
>
> This runs fine when run using the Groovy commandline.
>
> When running as a unit test in Eclipse I get the following:
>
> java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(Unknown Source)
>        at AcmeTest.class$(AcmeTest.groovy)
>        at AcmeTest.$get$$class$groovy$util$CliBuilder(AcmeTest.groovy)
>        at AcmeTest.setUp(AcmeTest.groovy:3)
>        at junit.framework.TestCase.runBare(TestCase.java:132)
>        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.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
>        at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
>        at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>        at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> Caused by: java.lang.ClassNotFoundException:
> org.apache.commons.cli.ParseException
>        at java.net.URLClassLoader$1.run(Unknown Source)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(Unknown Source)
>        at java.lang.ClassLoader.loadClass(Unknown Source)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>        at java.lang.ClassLoader.loadClass(Unknown Source)
>        ... 19 more
>
> Using   Groovy-Eclipse Feature    2.1.0.xx-20101007-1100-e36-RC2
> org.codehaus.groovy.eclipse.feature.feature.group
>
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/Groovy-Unit-test-not-running-with-CliBuilder-tp1737012p1737012.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Groovy Unit test not running with CliBuilder

MikeM
Andrew,

Is this a bug?
If it is by design then what is the rationale? I would expect that all required jars are included by default, so that the behavior in Eclipse matches the behavior when running from the commandline.
Thanks,
Mike
Reply | Threaded
Open this post in threaded view
|

Re: Groovy Unit test not running with CliBuilder

Andrew Eisenberg
We should probably include all of these jars on the classpath:

http://jira.codehaus.org/browse/GRECLIPSE-863

On Thu, Oct 21, 2010 at 1:21 AM, MikeM <[hidden email]> wrote:

>
> Andrew,
>
> Is this a bug?
> If it is by design then what is the rationale? I would expect that all
> required jars are included by default, so that the behavior in Eclipse
> matches the behavior when running from the commandline.
> Thanks,
> Mike
>
> --
> View this message in context: http://groovy-eclipse-plugin.42567.n3.nabble.com/Groovy-Unit-test-not-running-with-CliBuilder-tp1737012p1744211.html
> Sent from the groovy-eclipse-plugin-user mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email