@RunWith vs extends Specification

1,356 views
Skip to first unread message

Erem

unread,
Nov 26, 2009, 6:35:25 PM11/26/09
to Spock Framework
> [from the GREclipse thread]
>This is a bit off-topic, but @RunWith isn't necessary when you extend from class >Specification (which will become mandatory in Spock 0.4).

I gathered from the documentation that this was the case, but if I
don't have @RunWith(Sputnik) then eclipse refuses to run the spec as a
JUnit test. When I try to, it instead it pops up an alert dialog
entitled "JUnit Launch" which contains the text "No JUnit tests found"

For example, this doesn't run but removing the comment does.

=======
import org.junit.runner.RunWith;

import spock.lang.Specification;
import spock.lang.Sputnik;

//@RunWith(Sputnik)
class HelloSpock extends Specification {
def "can you figure out what I'm up to?"() {
expect:
name.size() == size

where:
name << ["Kirk", "Spock", "Scotty"]
size << [4, 5, 6]
}
}

Erem

unread,
Nov 26, 2009, 6:39:10 PM11/26/09
to Spock Framework
there was supposed to be a close-braces at the bottom of that class...

Peter Niederwieser

unread,
Nov 27, 2009, 12:32:27 PM11/27/09
to Spock Framework
Which version of the Groovy Eclipse plugin are you using? I just
updated from http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.5,
and running the specs in spock-examples works fine for me.

Erem

unread,
Nov 27, 2009, 3:51:04 PM11/27/09
to Spock Framework
Hey Peter,

I just updated to the latest version from the update site and it still
doesn't work w/o @RunWith(Sputnik). Here are all the versions I'm
using. Tell me anything else to provide that would be helpful (e.g.
screen video, zipped project, whatever).

Versions
Groovy-Eclipse plugin=2.0.0.xx-20091126-2100-e35 (just updated from
repo)
spock=0.3-groovy-1.7-SNAPSHOT.jar
junit4=4.5.0.v20090824
jvm=java-1.6.0-openjdk-1.6.0
eclipse
platform=3.5.1.R35x_v20090910-9gEeG1_FthkNDSP2odXdThaOu9GFDPn83DGB7

On Nov 27, 9:32 am, Peter Niederwieser <pnied...@gmail.com> wrote:
> Which version of the Groovy Eclipse plugin are you using? I just
> updated fromhttp://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.5,

Peter Niederwieser

unread,
Nov 27, 2009, 7:00:40 PM11/27/09
to spockfr...@googlegroups.com
Strange. Can you try with 0.4-groovy-1.7-SNAPSHOT and JUnit 4.7? If that doesn't help, I suggest to bring this up on the Groovy Eclipse plugin list.
> --
>
> You received this message because you are subscribed to the Google Groups "Spock Framework" 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.
>
>

Peter Niederwieser

unread,
Dec 10, 2009, 8:56:43 PM12/10/09
to Spock Framework
Erem,

have you been able to solve this problem?

Cheers,
Peter

Erem

unread,
Dec 16, 2009, 6:27:56 PM12/16/09
to Spock Framework
Hey Peter,

Sorry for taking so long on the response. I think the guys at the
eclipse plugin must have fixed it at some point; now it works fine w/o
@RunWith!

Erem

Erem

unread,
Dec 16, 2009, 6:45:43 PM12/16/09
to Spock Framework
Ugh nevermind. Seems like without @RunWith(Sputnik) I can run
INDIVIDUAL feature methods in line but not the entire set of feature
methods.

I tried upgrading to 0.4-groovy-1.7-SNAPSHOT but haven't tried junit
4.7 yet...

Peter Niederwieser

unread,
Dec 16, 2009, 6:51:30 PM12/16/09
to spockfr...@googlegroups.com
Erem,

Have you tried running a spec by right-clicking the spec CLASS in the Eclipse project explorer? Running a spec by right-clicking the spec FILE doesn't work yet. This is a known problem that the Groovy Eclipse folks are trying to fix right now.

Cheers,
Peter

Reply all
Reply to author
Forward
0 new messages