Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Support coverage for spawned (Java) child processes (Feature request) #100

Open
nlang5555 opened this issue Mar 29, 2015 · 1 comment
Open

Comments

@nlang5555
Copy link

The desired use case is to collect coverage when JUnit testing a Java 'main' class. Typically, such a 'main' class is tested by spawning it in its own process during the JUnit test. A naive process execution (e.g. exec 'java acme.Main') cannot collect coverage, since it does not load the JaCoCo agent. So, it is understood that at least some JaCoCo argument must be passed in the exec line. However, it is hard to see how that argument can be properly constructed from within the JUnit test. At least the following is unknown/hard to obtain:

  • Exact classpath of the jacoco agent
  • Port of the Jacoco server
  • Sessionid to be used

Ideally, the Emma plugin would make the required JaCoCo argument available as a 'defined' property, e.g. 'jacoco.jvm.arg', available for application during the JUnit test. In this way, child processes can easily be constructed with the appropriate JaCoco configuration argument.

@marchof
Copy link
Member

marchof commented Mar 30, 2015

Some random remarks:

  • The agent parameter could be obtained from the RuntimeMXBean:

    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    System.out.println(runtimeMXBean.getInputArguments());

  • The EclEmma plug-in currently accepts a single connection per launch only. For multiple connections we have to clarify whether they create different sessions or get merged into the same session. If a dump is requested from a running VM should the child processes also considered?

  • As a workaround you could configure a file output location for the child processes and import/merge the created exec file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants