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);
}
}
error when running with mvn test:
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)
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>
I have test with several versions, here is the result:
| jacoco maven plugin version |
result |
| 0.7.2.201409121644 |
success |
| 0.7.7.201606060606 |
success |
| 0.7.8 |
error |
| 0.8.2 |
error |
Almost the same as this issue: ERROR : Maven test fails to run moco server when using jacoco maven plugin.. Since it is closed, so I created this new issue instead.
test case code:
error when running with
mvn test:configuration in pom.xml:
I have test with several versions, here is the result:
Almost the same as this issue: ERROR : Maven test fails to run moco server when using jacoco maven plugin.. Since it is closed, so I created this new issue instead.