-
Hi, We have a quarkus instance running on our remote test environment and started it up with Jacoco javaagent in server mode:
There is also a service listening on port 9300. Then we trigger (plain jUnit5) Selenium Tests against an Angular Frontend which calls Rest APIs in quarkus. Then we try to get the Code Coverage Report from Jacoco server with the JacocoClient below. package xxx.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import org.jacoco.core.data.ExecutionDataWriter;
import org.jacoco.core.runtime.RemoteControlReader;
import org.jacoco.core.runtime.RemoteControlWriter;
public class JacocoClient {
private static final String DESTFILE = "C:\\temp\\jacoco-client.exec";
private static final String ADDRESS = "localhost";
private static final int PORT = 9300;
public static void main(final String[] args) throws IOException {
File f = new File(DESTFILE);
try (FileOutputStream localFile = new FileOutputStream(f)) {
System.out.println("File path: " + localFile);
final ExecutionDataWriter localWriter = new ExecutionDataWriter(localFile);
// Open a socket to the coverage agent:
try (Socket socket = new Socket(InetAddress.getByName(ADDRESS), PORT)) {
final RemoteControlWriter writer = new RemoteControlWriter(socket.getOutputStream());
final RemoteControlReader reader = new RemoteControlReader(socket.getInputStream());
reader.setSessionInfoVisitor(localWriter);
reader.setExecutionDataVisitor(localWriter);
// Send a dump command and read the response:
writer.visitDumpCommand(true, false);
if (!reader.read()) {
throw new IOException("Socket closed unexpectedly.");
}
socket.close();
}
}
}
} Any clue what we are missing here? Can you give us a hint! Or does this technique not work with quarkus at all? I know there is a documentation about it and how to use Quarkus + Jacoco locally and we also use Jacoco in our plain unit tests (@QuarkusTest) but for my Scenario I couldn't find anything ... Thanks in advance Max |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry my fault - I forgot to add: Seems to work now .. closing |
Beta Was this translation helpful? Give feedback.
Sorry my fault - I forgot to add:
quarkus.package.write-transformed-bytecode-to-build-output=true
during build.
Seems to work now .. closing