I have some Spring tests which spin up the application context and tests some services. I am able to run these tests using Maven and through IDE. Now I have a requirement to
I have just forked your repository and I found the error. Spring factory must be the same than the one is used when test are thrown by maven. It is a must to delegate into Spring Ic in the same way like test context.
See pull request for aditional information:
https://github.com/SaiUpadhyayula/executabletests/pull/2
I finally found the problem after debugging the test, it turns out that Spring while bootstrapping the TestContext will look for the TestExecutionListener's defined inside the META-INF/spring.factories file inside the spring-test jar.
This spring.factories file should be ideally placed inside the META-INF folder of my executable jar. But what the assembly-plugin does is, it was not adding the right spring.factories file which contains the necessary TestExecutionListener's
adding this file to src/main/resources/META-INF/spring.factories solved the problem
# Default TestExecutionListeners for the Spring TestContext Framework
#
org.springframework.test.context.TestExecutionListener = \
org.springframework.test.context.web.ServletTestExecutionListener,\
org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener,\
org.springframework.test.context.support.DependencyInjectionTestExecutionListener,\
org.springframework.test.context.support.DirtiesContextTestExecutionListener,\
org.springframework.test.context.transaction.TransactionalTestExecutionListener,\
org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
# Default ContextCustomizerFactory implementations for the Spring TestContext Framework
#
org.springframework.test.context.ContextCustomizerFactory = \
org.springframework.test.context.web.socket.MockServerContainerContextCustomizerFactory
You need to install maven on the other machine to run the tests.
If maven installation is not an viable option, create a jar containing the test classes and use this jar for running the tests. check the maven documentation - http://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html