With Maven I managed to get the coverage data adding this plugin to the pom:
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.2</version> <executions> <execution> <goals> <goal>prepare-agent</goal> </goals> </execution> <!-- attached to Maven test phase --> <execution> <id>report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin> The problem is that it forces the students to look under the hood in the project structure. Also I missed the branch coverage information. It seems to be counting only line coverage, as far as I know. With Gradle I cannot even run the tests. I am not a Gradle user so maybe I missed something. Here it is the output: JAVA_HOME="C:\Program Files\Java\jdk-11.0.2" cd C:\Users\Eduardo\Documents\NetBeansProjects\gradleproject1; C:\Users\Eduardo\.gradle\wrapper\dists\gradle-4.10.2-bin\cghg6c4gf4vkiutgsab8yrnwv\gradle-4.10.2\bin\gradle --configure-on-demand --rerun-tasks -x check test Configuration on demand is an incubating feature. > Task :compileJava > Task :processResources NO-SOURCE > Task :classes > Task :compileTestJava > Task :processTestResources NO-SOURCE > Task :testClasses Could not write standard input to Gradle Test Executor 1. java.io.IOException: Se est cerrando la canalizacin at java.base/java.io.FileOutputStream.writeBytes(Native Method) at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354) at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81) at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142) at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:66) at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:51) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.base/java.lang.Thread.run(Thread.java:834) > Task :test FAILED Exception in thread "main" java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:513) at java.instrument/sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:525) Caused by: java.lang.RuntimeException: Class java/lang/UnknownError could not be instrumented.FATAL ERROR in native method: processing of -javaagent failed at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:140) at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:101) at org.jacoco.agent.rt.internal_c13123e.PreMain.createRuntime(PreMain.java:55) at org.jacoco.agent.rt.internal_c13123e.PreMain.premain(PreMain.java:47) ... 6 more Caused by: java.lang.NoSuchFieldException: $jacocoAccess at java.base/java.lang.Class.getField(Class.java:2000) at org.jacoco.agent.rt.internal_c13123e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138) ... 9 more ________________________________ De: Laszlo Kishalmi <laszlo.kisha...@gmail.com> Enviado: sábado, 25 de mayo de 2019 1:49 Para: users@netbeans.apache.org Asunto: Re: JaCoCoverage plugin Hi! Actually JaCoCo support is out-of-the box in NetBeans, the additional plugin was required for Ant Based projects and it is not maintained right now (AFAIK it still has to be contributed by Oracle to Apache) So JaCoCo with Maven project do work though it require some configuration in the pom.xml. I'd say the easiest way is to achieve it if you just create a new Gradle Project from the IDE: File > New Project > Java with Gradle > Java Application | Java Class Library The new project will be created with Gradle's Jacoco plugin applied. NetBeans recognize that, so right clicking the project there will be a Code Coverage menu where you can enable the collection of the coverage results. From that point whenever some unit tests were executed the code coverage results would be updated. on 5/24/19 3:54 PM, Eduardo Mosqueira Rey wrote: Hi all, I used in classroom the JaCoCoverage plugin with NetBeans 8.2 for the students to check the coverage of their tests. It had an easy and straightforward installation and was very simple to use, ideal for newbies. Nevertheless, the plugin is no longer maintained at it doesn’t work with NetBeans 11.0. This year I want to migrate the classroom installation to Apache NetBeans but the lack of a coverage tool is an inconvenient. Is there an easy way to install a Coverage tool (whatever) in NetBeans 11.0? *easy to install* is an important requirement. Any suggestion would be appreciated. Many thanks, -- Eduardo