How Clover writes coverage data to disk at runtime can be configured by changing Clover's flush policy. Clover provides three policies: directed
, interval
and threaded
. The default mode is directed
. The flush policy is set at instrumentation time, either via the <clover-setup>
Ant task, or via the IDE plugin configuration screen.
Which flush policy you choose depends on the runtime environment in which the instrumented code is executing. In the most common unit testing scenarios, the default flush policy will suffice. In situations where instrumented code is executing in a hosted environment (e.g. a J2EE container) and shutting down the JVM at the end of testing is not desirable, you will want to use one of the interval-based flush policies.
Policy |
Description |
directed |
default. Coverage recordings are flushed only when the hosting JVM is shut down, or where the user has directed a flush using the ///CLOVER:FLUSH inline directive. Directed flushing has the lowest runtime performance overhead of all flush policies (depending on the use of the flush inline directive). Note that no coverage recordings will be written if the hosting JVM is not shut down, or if the hosting JVM terminates abnormally. |
interval |
The interval policy flushes as per the directed policy, and also at a maximum rate determined by the interval set at instrumentation time (see the flushinterval attribute on <clover-setup> ). The interval mode is a 'passive' mode in that flushing potentially occurs only while instrumented code is still being executed. There exists the possibility that coverage data recorded just prior to the end of execution of instrumented code may not be flushed, because the flush interval has not elapsed between the last flush and the end of execution of instrumented code. Any coverage not flushed in this manner will be flushed if/when the hosting JVM shuts down. The interval policy should be used in environments where shutdown of the hosting JVM is not practical and thread creation by Clover is not desired. If you don't mind Clover creating a thread, use the threaded policy. Runtime performance overhead is determined by the flush interval. |
threaded |
The threaded policy flushes as per the directed policy, and also at a rate determined by the interval set at instrumentation time (see the flushinterval attribute on <clover-setup> ). The threaded mode starts a separate thread to perform flushes. The threaded policy should be used in environments where shutdown of the hosting JVM is not practical. Runtime performance overhead is determined by the flush interval. |