IntelliJ Code Coverage for Integration Tests

Is there a way to get the IntelliJ IDEA Code Coverage tool to run during integration tests (or any other arbitrary maven phase)?  For example, when developing a server (jetty/tomcat/google app engine), it is common practice to start that server up during the pre-integration-test phase, and shut it down during the post-integration-test phase.  Your integration tests can then hit the server.  It looks to me (from the log that is written out by TeamCity) that the Code Coverage plugin is getting loaded during the integration phase itself...meaning that my integration tests (which *don't* actually test any of my code) is not run - rather than running coverage on the server that was started during pre-integration-test.

Here is a smal snippet of my TeamCity output:

[16:44:49][com.k9webprotection:server] [INFO] --- maven-gae-plugin:0.9.6-SNAPSHOT:start (start-gae) @ server ---
[16:44:50][com.k9webprotection:server] 2013-03-20 16:44:49.491 java[2477:707] [Java CocoaComponent compatibility mode]: Enabled
[16:44:50][com.k9webprotection:server] 2013-03-20 16:44:49.498 java[2477:707] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
[16:44:51][com.k9webprotection:server] INFO: Directory '/Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged' is not an EAR directory. File /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/appengine-application.xmlappengine-application.xml not detected.
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
[16:44:51][com.k9webprotection:server] INFO: Directory '/Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged' is not an EAR directory. File /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/appengine-application.xmlappengine-application.xml not detected.
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
[16:44:51][com.k9webprotection:server] INFO: Directory '/Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged' is not an EAR directory. File /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/appengine-application.xmlappengine-application.xml not detected.
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.apphosting.utils.config.EarHelper logNotAnEar
[16:44:51][com.k9webprotection:server] INFO: Directory '/Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged' is not an EAR directory. File /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/appengine-application.xmlappengine-application.xml not detected.
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
[16:44:51][com.k9webprotection:server] INFO: Successfully processed /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/WEB-INF/appengine-web.xml
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
[16:44:51][com.k9webprotection:server] INFO: Successfully processed /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/WEB-INF/web.xml
[16:44:51][com.k9webprotection:server] Mar 20, 2013 4:44:50 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
[16:44:51][com.k9webprotection:server] INFO: Overwriting system property key 'java.util.logging.config.file', value '/Applications/buildAgent/system/jetbrains.maven.runner/maven.repo.local-bt9/com/google/appengine/appengine-java-sdk/1.7.5/appengine-java-sdk-1.7.5/config/sdk/logging.properties' with value 'WEB-INF/classes/logging.properties' from '/Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/WEB-INF/appengine-web.xml'
[16:44:51][com.k9webprotection:server] Mar 20, 2013 10:44:50 PM com.google.apphosting.utils.jetty.JettyLogger info
[16:44:51][com.k9webprotection:server] INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
[16:44:51][com.k9webprotection:server] Mar 20, 2013 10:44:50 PM com.google.apphosting.utils.jetty.JettyLogger info
[16:44:51][com.k9webprotection:server] INFO: jetty-6.1.x
[16:44:52][com.k9webprotection:server] Mar 20, 2013 10:44:51 PM com.google.apphosting.utils.jetty.JettyLogger info
[16:44:52][com.k9webprotection:server] INFO: Started SelectChannelConnector@0.0.0.0:8080
[16:44:52][com.k9webprotection:server] [INFO]
[16:44:52][com.k9webprotection:server] Mar 20, 2013 10:44:51 PM com.google.appengine.tools.development.AbstractServer startup
[16:44:52][com.k9webprotection:server] INFO: Server default is running at http://localhost:8080/
[16:44:52][com.k9webprotection:server] [INFO] --- maven-failsafe-plugin:2.13:integration-test (default) @ server ---
[16:44:52][com.k9webprotection:server] Mar 20, 2013 10:44:51 PM com.google.appengine.tools.development.AbstractServer startup
[16:44:52][com.k9webprotection:server] INFO: The admin console is running at http://localhost:8080/_ah/admin
[16:44:52][com.k9webprotection:server] Mar 20, 2013 10:44:51 PM com.google.appengine.tools.development.DevAppServerImpl start
[16:44:52][com.k9webprotection:server] INFO: Dev App Server is now running
[16:44:53][com.k9webprotection:server] [INFO] Failsafe report directory: /Applications/buildAgent/work/10b0ec880461d6ac/server/./target/server/failsafe-reports
[16:44:53][com.k9webprotection:server]
[16:44:53][com.k9webprotection:server] -------------------------------------------------------
[16:44:53][com.k9webprotection:server] T E S T S
[16:44:53][com.k9webprotection:server] -------------------------------------------------------
[16:44:54][com.k9webprotection:server] ---- IntelliJ IDEA coverage runner ----
[16:44:54][com.k9webprotection:server] sampling ...
[16:44:54][com.k9webprotection:server] include patterns:
[16:44:54][com.k9webprotection:server] com\.k9webprotection\.server\..*
[16:44:54][com.k9webprotection:server] exclude patterns:
[16:44:54][com.k9webprotection:server] Running com.k9webprotection.server.ITServerProt
[16:44:54][com.k9webprotection:server] Mar 20, 2013 10:44:53 PM com.google.appengine.tools.development.DevAppEngineWebAppContext disableTransportGuarantee
[16:44:54][com.k9webprotection:server] INFO: Ignoring <transport-guarantee> for /task/client/register as the SDK does not support HTTPS.  It will still be used when you upload your application.
[16:44:55][com.k9webprotection:server] Mar 20, 2013 10:44:54 PM com.google.appengine.api.datastore.dev.LocalDatastoreService init
[16:44:55][com.k9webprotection:server] INFO: Local Datastore initialized:
[16:44:55][com.k9webprotection:server] Type: Master/Slave
[16:44:55][com.k9webprotection:server] Storage: /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/WEB-INF/appengine-generated/local_db.bin
[16:44:55][com.k9webprotection:server] Mar 20, 2013 10:44:54 PM com.google.appengine.api.datastore.dev.LocalDatastoreService load
[16:44:55][com.k9webprotection:server] INFO: The backing store, /Applications/buildAgent/work/10b0ec880461d6ac/server/target/server/server-1.0.7-merged/WEB-INF/appengine-generated/local_db.bin, does not exist. It will be created.
[16:44:57][com.k9webprotection:server] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.887 sec
[16:44:57][com.k9webprotection:server]
[16:44:57][com.k9webprotection:server] Results :
[16:44:57][com.k9webprotection:server]
[16:44:57][com.k9webprotection:server] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[16:44:57][com.k9webprotection:server]
[16:44:57][com.k9webprotection:server] [INFO]
[16:44:57][com.k9webprotection:server] [INFO] --- maven-gae-plugin:0.9.6-SNAPSHOT:stop (stop-gae) @ server ---
[16:44:57][com.k9webprotection:server] [INFO]

I'd like to be able to bind the "IntelliJ IDEA coverage runner" to the process that is actually running the server - rather than the process that is running the integration tests.  How can I configure that?
1 comment
Comment actions Permalink

I found a solution - I just had to set the javaAgent flag for the parameter I was using.  The following profile achieves this on the teamcity server

          <!-- If we have a failsafe debug value set, we modify it for gae -->

          <profile>

               <id>failsafe-debug</id>

               <activation>

                    <property><name>maven.failsafe.debug</name></property>

               </activation>

               <build>

                    <plugins>

                         <plugin>

                              <groupId>org.codehaus.mojo</groupId>

                              <artifactId>build-helper-maven-plugin</artifactId>

                              <executions>

                                   <execution>

                                        <id>failsafe-regex-property</id>

                                        <goals><goal>regex-property</goal></goals>

                                        <configuration>

                                             <name>gae.javaAgent</name>

                                             <value>${maven.failsafe.debug}</value>

                                             <regex>^.*-javaagent:([^ '"]*).*$</regex>

                                             <replacement>$1</replacement>

                                        </configuration>

                                   </execution>

                              </executions>

                         </plugin>

                    </plugins>

               </build>

          </profile>

0

Please sign in to leave a comment.