Skip to content

Maven test fails to run moco server when using jacoco maven plugin 0.7.8 or newer #816

@chenhengjie123

Description

@chenhengjie123

This is a issue tracker. Please use our mailing list for general questions:
https://groups.google.com/forum/?fromgroups=#!forum/jacoco

Also check FAQ before opening an issue: http://www.jacoco.org/jacoco/trunk/doc/faq.html

Steps to reproduce

test case code:

import com.github.dreamhead.moco.Moco;
import com.github.dreamhead.moco.junit.MocoJunitRunner;
import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;

public class BzdWithdrawHisServiceImplTest {
    @Rule
    public MocoJunitRunner runner = MocoJunitRunner.jsonHttpRunner(12306, Moco.pathResource("foo.json"));

    @Test
    public void  mockTest() throws IOException {
        HttpResponse httpResponse = Request.Get("http://localhost:12306").execute().returnResponse();
        System.out.println(httpResponse);
    }
}

configuration in pom.xml:

...
        <!-- https://mvnrepository.com/artifact/com.github.dreamhead/moco-junit -->
        <dependency>
            <groupId>com.github.dreamhead</groupId>
            <artifactId>moco-junit</artifactId>
            <version>0.12.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/com.github.dreamhead/moco-runner -->
        <dependency>
            <groupId>com.github.dreamhead</groupId>
            <artifactId>moco-runner</artifactId>
            <version>0.12.0</version>
        </dependency>
...
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.maven.plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

error occurs when running mvn test to run tests with jacoco.

JaCoCo version: multiple, mentioned in Actual behaviour
Operating system: occurs on mac os 10.14 and windows 7
Tool integration: Maven/Ant/API/Other: maven

Expected behaviour

mvn test could run well

Actual behaviour

when running mvn test, error occurs like below:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.355 sec <<< FAILURE! - in com.ppmoney.feastful.fc.BzdWithdrawHisServiceImplTest
mockTest(com.ppmoney.feastful.fc.BzdWithdrawHisServiceImplTest)  Time elapsed: 0.012 sec  <<< ERROR!
java.lang.IllegalArgumentException: unknown field [$jacocoData]
	at com.ppmoney.feastful.fc.BzdWithdrawHisServiceImplTest.<init>(BzdWithdrawHisServiceImplTest.java:15)
jacoco maven plugin version result
0.7.2.201409121644 success
0.7.7.201606060606 success
0.7.8 error
0.8.2 error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions