I am new to the gradle tool, and I am trying to add the support for running integration test using the jetty plugin in gradle. I came across two posts, one and two, but the difference in my approach is, that I am not using a separate source set for integration tests. My integration tests are named following the pattern,
" **/ITCase*.*".
My project has 4 child modules, and I am setting up the integration test for the services modules. Using the example here , I set up the jetty configuration:
[jettyRun, jettyStop]*.stopPort = 8006
[jettyRun,jettyStop]*.stopKey = 'STOP'
jettyRun {
classpath=configurations.compile
}
task integrationTest(type: Test, dependsOn: "test" ) {
include '**/*ITCase*.*'
println 'Starting the embedded jetty'
doFirst {
jettyRun.daemon = true
jettyRun.scanIntervalSeconds = 0
jettyRun.execute()
}
doLast {
jettyStop.execute()
println 'Stopping the embedded jetty'
}
}
"test" is a task defined in the parent project's build.gradle.
When I run the command, gradle war integrationTest, the integration tests fails as it cannot find the context listener in the services project. A snippet of the error message is as follows:
:services:integrationTest (Thread[Daemon Thread 14,5,main]) started.
:services:integrationTest
Executing task ':services:integrationTest' (up-to-date check took 0.026 secs) due to:
No history is available.
Starting the embedded jetty
Executing task ':services:jettyRun' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Configuring Jetty for project ':services'
Webapp source directory = E:\Workspace\project\services\src\main\webapp
Reload Mechanic: automatic
web.xml file = E:\Workspace\project\services\src\main\webapp\WEB-INF\web.xml
Context path = /services
Tmp directory = determined at runtime
Web defaults = org/mortbay/jetty/webapp/webdefault.xml
Web overrides = none
Webapp directory = E:\Workspace\project\services\src\main\webapp
Starting jetty 6.1.25 ...
jetty-6.1.25
Could not instantiate listener com.db.project.services.ProjectServletContextListener
java.lang.ClassNotFoundException: com.db.project.services.ProjectServletContextListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:401)
at org.mortbay.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:363)
at org.mortbay.jetty.handler.ContextHandler.loadClass(ContextHandler.java:1101)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initListener(WebXmlConfiguration.java:630)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initWebXmlElement(WebXmlConfiguration.java:368)
at org.mortbay.jetty.plus.webapp.AbstractConfiguration.initWebXmlElement(AbstractConfiguration.java:190)
at org.mortbay.jetty.webapp.WebXmlConfiguration.initialize(WebXmlConfiguration.java:289)
Any help on this is appreciated. Thanks in advance