Skip to content

TestContext extracted to interface in Spring 4 #46

erfranco opened this Issue Dec 17, 2013 · 9 comments

6 participants


Upgrading tests from Spring 3.2.6 (all worked well) to Spring 4.0.0, recently released, an error arises:
java.lang.IncompatibleClassChangeError: Found interface org.springframework.test.context.TestContext, but class was expected
at com.github.springtestdbunit.TestExecutionListenerChain.runChain( ~[spring-test-dbunit-1.0.1.jar:na]

This is due to the fact that the TestContext is now an interface, so the DefaultTestContext (or another implementation) should be fed to the chain


I have the same issue and if you upgrade spring-test-dbunit to use spring-test 4.0.0.RELEASE everything works well. The problem is that the projects with 3.x.x spring will not work with spring-test-dbunit which depends on spring 4 and vice versa ...


Thanks for the advice, but how can you upgrade spring-test-dbunit? To say, do you recompile changing the spring-test-dbunit pom.xml?

@erfranco erfranco closed this Dec 17, 2013
@erfranco erfranco reopened this Dec 17, 2013
@philwebb philwebb added a commit that referenced this issue Dec 17, 2013
@philwebb philwebb Use reflection to access TestContext
Use reflection to access Spring's TestContext to protect against
IncompatibleClassChangeError caused by the fact that it changed from
a class to an interface between Spring 3.2 and 4.0

Issue: #46

I have started a 1.1.0 version on master that targets Spring 4.0 whilst remaining compatible with Spring 3.2.

Could you try building the latest master and let me know if that works for you.

@philwebb philwebb closed this Dec 17, 2013

All is ok.
I have installed locally 1.1.0-SNAPSHOT, upgrading java.version property to 1.6, as Spring 4 requires, and adding ${java.version} to the compiler.
Thanks for publishing in snapshot repository.


<target>${java.version}<target> (apologize html enities...)


I did the same and it worked. Some tests still fail, but mostly regarding the @Rule support, but since that feature will be dropped it doesn't matter. Also, 'mvn install' failed, in fact to be able to complete this I had to exclude all tests from the maven lifecycle. Also, I had to change the com.github.springtestdbunit.testutils.ExtendedTestContextManager class and replace this line: getTestContext().markApplicationContextDirty(); with getTestContext().markApplicationContextDirty(DirtiesContext.HierarchyMode.EXHAUSTIVE); ... to able to compile the code.


Sorry if I'm a bit out of the loop here, I tried to line up this thread to the commit histories and maven artifact publish history, but thought i should ask just to make sure, has the 1.1.0 artifact been published and verified to continue to work with spring 3.2.x? I'm still seeing this issue when using spring 3.2.8, downgrading to 1.0.1 solves it for now, but I was hoping to leverage the query feature in the expected database annotation introduced in 1.1.0.

Great work by the way!

nowakp1 commented Mar 19, 2014

I have the same issue at Spring 3.2.0. With version 1.0.1 it works fine but with version 1.1.1 I get the error about TestContext. I suggest to add small note about dependence between dbUnit version and Spring version at main documentation page.

rodsong commented Nov 20, 2014

can use


@brasmusson brasmusson referenced this issue in cucumber/cucumber-jvm Feb 17, 2015

Cucumber Spring is not finding my step definitions #835

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.