Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringMockTestExecutionListener is only applicable for spock specifications. #802

Closed
ANeumann82 opened this issue Jan 5, 2018 · 3 comments

Comments

@ANeumann82
Copy link
Contributor

Help us help you

We are glad you are reporting your issue.

Please follow these guidelines when so we better can classify the issue.

The more info you provide about your environment and how to reproduce the problem the easier and faster it will be to solve (win-win).

Please check existing issues (both open and closed) prior to opening any new issue.
Optionally make sure it is a bug by other users in forum, StackOverflow Spock questions, etc.

The block quotes can be omitted.
Most of the sections are only applicable for bugs.

Issue description

We have a couple of old unit tests, and now starting to work with Spock. I've started to integrate spock-spring, and now on my old Tests annotated with @ContextConfiguration I get an Exception.

I understand that the SpringMockTestExecutionListener should only apply to Spock tests, but i'm not sure if it actually should throw Exceptions for non-spock tests.

How to reproduce

Create a new Non-Spock-Test (Junit, with spring and @ContextConfiguration) that does not extend spock.lang.Specification
Trying to run a test from that class leads to an Exception:
java.lang.IllegalArgumentException: SpringMockTestExecutionListener is only applicable for spock specifications.

at org.spockframework.spring.SpringMockTestExecutionListener.beforeTestMethod(SpringMockTestExecutionListener.java:87)
at org.spockframework.spring.AbstractSpringTestExecutionListener.beforeTestMethod(AbstractSpringTestExecutionListener.java:39)
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:269)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Link to a gist or similar (optional)

Additional Environment information

Java/JDK

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Groovy version

Groovy Version: 2.4.7 JVM: 1.8.0_121 Vendor: Oracle Corporation OS: Mac OS X

Build tool version

Apache Maven

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"

Operating System

Mac

IDE

IntelliJ

Build-tool dependencies used

Gradle/Grails

compile 'org.spockframework:spock-core:1.1-groovy-2.4-rc-2'

Apache Maven

	<dependency>
		<groupId>org.spockframework</groupId>
		<artifactId>spock-core</artifactId>
		<version>1.2-groovy-2.4-20180103.081335-38</version>
		<scope>test</scope>
	</dependency>
	<dependency>
		<groupId>org.spockframework</groupId>
		<artifactId>spock-spring</artifactId>
		<version>1.2-groovy-2.4-20180103.081345-38</version>
		<scope>test</scope>
	</dependency>
@ANeumann82
Copy link
Contributor Author

#803 I've added a pull request to fix this issue. @leonard84 could you have a look at that, you seem to be more in touch with the code there. Thanks

@leonard84
Copy link
Member

@derBiggi good catch, that is why it is important to have people that use the snapshots. I'll take a look at your PR this Weekend.

leonard84 pushed a commit that referenced this issue Jan 9, 2018
…-spock-tests … (#803)

* Removed thrown IllegalArgumentException to make sure non-spock-tests executed by SpringRunner don't fail
@leonard84
Copy link
Member

@derBiggi thanks for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants