|
This page contains instructions on how to collect per-test coverage from a set of functional tests, which run in multiple JVMs (Java Virtual Machines). This may be necessary when starting a web server with the Jetty Runner or Tomcat Tasks, for example. On this page:
General OverviewClover collects per-test coverage for tests running in a separate JVM by sending messages using the tcp protocol. The JVM hosting the tests is the 'Clover Server' and the JVM(s) hosting the application are the 'Clover Clients'. The 'Clover Server' ( ie. the JVM running your tests) needs to be marked as such via a System Property: 'clover.server=true'. If this property is not set, or is set to 'false', the JVM will be in 'Clover Client' mode. If you are testing multiple projects on the same machine at the same time (such as in a Continuos Integration environment), you will need to ensure a unique port for each build is reserved and configured. By default, Clover starts a socket server on port 1198. Distributed per-test coverage will give you insight as to what functional tests covered what application code. It also allows you to drastically reduce test execution time by using Clover's Test Optimization to only run the tests for code that was modified since the previous build. To configure Clover for collection of per-test coverage from distributed builds, you have two options:
Option 1. Enabling Distributed Coverage at RuntimeOnce your Clover-instrumented application has been deployed, and your tests have been instrumented and compiled with Clover, distributed per-test coverage can be enabled and configured at runtime using just two System Properties. Both JVMs require the For the following examples, we are using the Jetty Runner to start the Jetty Webserver, and the Ant JUnit Task to run the tests. Setting the System Properties in the Ant JUnit TaskSetting a System Property in the Java task that starts the WebServerThe JVM running your webserver also requires the If you are unable to set a System Property on the JVM running your webserver, use the second approach described below. Option 2. Configuring Distributed Coverage at Instrumentation TimeIt is sometimes more convenient to enable distributed Coverage when you enable Clover - before instrumentation of your source code. Step 1: Activate the Distributed Per-Test Coverage FeatureBoth the <clover-setup> and <clover-instr> tasks can be configured with this nested element: If this element is present, then Clover will run in 'distributed mode' at test time. If you wish to modify any configuration options such as the port to listen on, or the number of clients expected to attach to the testing session, you can specify these as attributes on the This will enable distributed per-test coverage to be collected. Please see the documentation for the <distributedCoverage/> element for more options. Step 2: Specify the 'clover.server' property on JVM running the TestsAdd the e.g. If you have specified the Related Links |
|
|
|
|
|






