1
submitted 10 months ago by azimir@lemmy.ml to c/java@lemmy.ml

This is kind of an open question for me: does any code coverage tool work in Java with Junit5? I'll admit that I'm no Java configuration specialist, so I find the complexity of XML-based configuration systems to be quite opaque. I've got a few simple Maven-based build projects on hand and I wanted to add code coverage to the test harnesses. Unfortunately, I have never managed to get one stood up and running. I do this all the time with Python pytest/coverage tools, but it's been elusive for Java projects.

Could someone here please point me to a working example of any Java project using Maven / Junit5 / [any code coverage system]?

My latest attempt to get a working example came from this howto: https://howtodoinjava.com/junit5/jacoco-test-coverage/

But, it once again gave me the: [INFO]


jacoco-maven-plugin:0.8.7:report (default-report) @ JUnit5Examples


[INFO] Skipping JaCoCo execution due to missing execution data file.

As near as I can tell, JaCoCo just never runs. Ever. It's been very frustrating. I've read tutorials, followed suggestions on configuring surefire in various ways. I've pulled misc repo that claim to have it working. I've tried different computers with different OSes, versions of java, different maven installs, etc. There's something somewhere that I'm missing and after months of off and on attempts to get this working I'm at my wit's end.

Please help.

top 1 comments
sorted by: hot top controversial new old
[-] Lysergid@lemmy.ml 2 points 10 months ago* (last edited 10 months ago)

Try official example from JUnit team. https://github.com/junit-team/junit5-samples/tree/r5.10.2/junit5-jupiter-starter-maven

Then add jacoco plugin with prepare-agent goal

this post was submitted on 10 Feb 2024
1 points (66.7% liked)

Java™ Community

476 readers
1 users here now

Write once, run anywhere (WORA)

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.

The community

News, Technical discussions, research papers and assorted things of interest related to the Java Platform.

Rules
  1. Follow the Code of Conduct.
  2. Please make sure its a question/topic/post that would be new to most members. In Lemmy the publications are not closed, so you can continue to participate in them, regardless of the time they were published.
  3. Lemmy doesn’t have flags yet, so please tag your posts with [Question], [Help], [Learning], [JVM], [JSE], [OpenJDK], [Eclipse] or other you may think is appropriate.

Related communities

Resources

founded 5 years ago
MODERATORS