Issue in running Spock Spec from within Eclipse

1,716 views
Skip to first unread message

Icarus

unread,
Jan 26, 2011, 4:30:47 AM1/26/11
to Spock Framework - User
Hi,

I am using Spock framework from within eclipse ( I downloaded the jar
- spock-core0.6-groovy-1.7 SANPSHOT jar )
and am using that with a Java project that I converted to a Groovy
Project.

I am trying to test some existing Java Classes from this Groovy
Project.

However, I am not able to run the project as it complains -
"java.lang.NoSuchMethodError: main
Exception in thread "main" .

Are there some intermediate steps that I am missing ?


Thanks,

Arun

Peter Niederwieser

unread,
Jan 26, 2011, 9:17:55 AM1/26/11
to spockfr...@googlegroups.com
Without more information (Eclipse version, stack trace, example project, etc.), it's impossible to say what the problem is. The general steps for using Spock with Eclipse are explained here: http://code.google.com/p/spock/wiki/GettingStarted#Eclipse

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To post to this group, send email to spockfr...@googlegroups.com.
To unsubscribe from this group, send email to spockframewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spockframework?hl=en.


Merlyn Albery-Speyer

unread,
Jan 27, 2011, 1:42:35 AM1/27/11
to spockfr...@googlegroups.com
Hey Arun,

Have you tried the groovy eclipse plugin mailing list? If you're out
of options you could try having Gradle generate your eclipse project.
If it's a classpath/dependency issue that would fix it:

------ build.gradle ------
apply plugin: 'groovy'
apply plugin: 'eclipse'

repositories {
mavenCentral()
}

dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.7.6'
testCompile 'org.spockframework:spock-core:0.5-groovy-1.7'
}
------ build.gradle ------
Once you have gradle installed, execute "gradle eclipse" from the
command-line.

Cheers,
Merlyn

Arun

unread,
Jan 27, 2011, 4:16:00 AM1/27/11
to Spock Framework - User
Hi Peter,

Here are the details of my installation and the steps I am taking :

Eclipse : Helios (20100617-1415)
Groovy Eclipse plugin : v2.1.2

Following Libraries have been added to the project:
- Groovy Libraries
- groovy-all-1.7.5.jar and remaining
ones for commons, ivy, jline and servlet-api
- JRE System Libraries
- JUnit 4

Referenced Library :
- spock-core-0.5-groovy-1.7.jar

Specification


class WorkflowTest extends spock.lang.Specification{


def "testing simple Spock Method"(){
expect:
name.size() == length
where:
name << ["Kirk", "Spock", "Scotty"]
length << [4,5,6]
}
}

When I try running the class as a JUnit Test, I get following error :

Class not found com.iconsole.test.WorkflowTest
java.lang.ClassNotFoundException: com.iconsole.test.WorkflowTest
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)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:
693)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:
429)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
452)
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)


Seems like the class file is not being generated. Am I missing some
step ?

Thanks,
Arun

Arun

unread,
Jan 27, 2011, 4:22:01 AM1/27/11
to Spock Framework - User
Hi Merlyn

I used the gradle file to generate a sample project. But still
getting the class not found error.

Class not found com.arun.test.SampleTest
java.lang.ClassNotFoundException: com.arun.test.SampleTest
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)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:
693)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:
429)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
452)
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)


Thanks for helping... but it seems I am missing some step for
generating the test class.

On Jan 27, 11:42 am, Merlyn Albery-Speyer

Merlyn Albery

unread,
Jan 27, 2011, 10:42:34 AM1/27/11
to spockfr...@googlegroups.com
Ok. Great. Next step is to check with the eclipse plugin user mailing list.

Peter Niederwieser

unread,
Jan 27, 2011, 10:46:51 AM1/27/11
to spockfr...@googlegroups.com
Seems like the spec doesn't get compiled. Does a clean build produce errors? Is there anything suspicious in the Eclipse log?

Cheers,
Peter

Arun

unread,
Jan 28, 2011, 2:58:38 AM1/28/11
to Spock Framework - User
Hi,

The issue was with my Class File. I was missing a package ...
statement.

Adding that statement allowed me to run the test.

Thanks,
Arun
Reply all
Reply to author
Forward
0 new messages