Number945
Number945

Reputation: 4940

Using Jacoco in eclipse

I am using eclipse with Buildship plugin. I have a gradle project in it with build.gradle as follows:

apply plugin: 'java'
apply plugin: 'jacoco'

version = '1.0'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.11'
}

The project just is to understand how should I do Unit testing. I want to use this plugin jacoco which is a code coverage tool. Following is the command :

gradle clean test jacocoTestReport

Now, I need a console to write this.

How should I write this command in eclipse?
OR
Is there a alternative GUI way for this in eclipse + Builship Plugin ?

Upvotes: 0

Views: 1959

Answers (2)

mlohbihler
mlohbihler

Reputation: 777

If you're like me you added the apply statement to your build script and then clicked the refresh button in your gradle tasks view, but didn't see the 'jacocoTestReport' task show up. This appears to be because it doesn't declare itself to be in a group. (I.e. one of build, build setup, documentation, help, upload, or verification.) I added the following to my script and refreshed again, and the jacoco task then appeared under verification.

task jacoco(group: 'verification', dependsOn: jacocoTestReport) {
}

Upvotes: 0

lance-java
lance-java

Reputation: 27984

I think the best way to see coverage in Eclipse is to install the EclEmma plugin which uses JaCoCo under the hood. Then you can

  1. Right click on a test class / test method
  2. Coverage as...
  3. JUnit test

Upvotes: 2

Related Questions