java - “IllegalStateException: Incompatible execution data for class in…” exception from Jacoco when run for an existing ear -
i’m trying test legacy big fat ear (app.ear) application using arquillian , testng. run test have added testable war file (test.war) in existing app.ear , deployed on wildfly 10 server remotely.
@deployment public static enterprisearchive createdeployment(){ return shrinkwrap.createfromzipfile(enterprisearchive.class, new file("../earapp/target/earapp-0.0.1-snapshot.ear")) .addasmodule(testable.archivetotest(shrinkwrap.create(webarchive.class, "test.war") .addclass(currencyconvertertest.class) .addaswebinfresource(emptyasset.instance, "beans.xml"))); }
the next part of requirement code coverage report after tests run. i’m using jacoco , running jacoco maven plugin.
<plugin> <groupid>org.jacoco</groupid> <artifactid>jacoco-maven-plugin</artifactid> <version>0.7.7.201606060606</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>default-report</id> <goals> <goal>report</goal> </goals> </execution> </plugin>
the app.ear gets deployed , tests running fine when comes generate report jacoco failing , exception “illegalstateexception: incompatible execution data class in jacoco ………”
the exception coming class contains test cases. if exclude class (currencyconvertertest.class) using exclusion tag in jacoco maven plugin exception goes away reports generated jacoco contains no data. i’ve checked jacoco.exec , far can contains valid data.
since cannot share proprietary code i’m working with, i’ve created 3 simple projects on github emulate same.
- project 1 (currencycoverter): project has 1 stateless ejb remote interface having 3 methods.
- project 2 (earapp): project creates ear file using project 1 ejb module.
- project 3 (eartest): project test ear generated project 2.
to me looks there bug in jacoco code might wrong also. please me out.
update: steps build projects shared on git repo
step 1: check out 3 projects , import eclipse eclipse projects.
step 2: run maven command clean instll project 1 (currencyconverter)
step 3: run maven command clean package project 2 (earapp). create ear file in target directory.
step 4: start wildfly 10 in standalone mode on local machine.
step 5: run maven command clean install project 3 (eartest). use ear generated in step 3 , deploy in wildfly 10 application server , run tests.
unfortunately example can't built:
[error] failed execute goal on project eartest: not resolve dependencies project com.sg.eartest:eartest:jar:0.0.1-snapshot: not find artifact org.jboss.osgi.metadata:jbosgi-metadata:jar:3.0.1.final in central (https://repo.maven.apache.org/maven2)
also simpler play it, if located in single github repository.
however:
make sure use exact same version of jacoco in modules under test.
and make sure jvm under test terminated gracefully, otherwise might receive corrupted "jacoco.exec" file, because default saved during jvm shutdown. in earlier versions of jacoco such corrupted files might cause
illegalstateexception: incompatible execution data class...
(as per https://github.com/jacoco/jacoco/issues/95#issuecomment-17271597)
the error message in case of truncated files has been improved in jacoco version 0.7.7 - https://github.com/jacoco/jacoco/pull/397 , practice use latest released versions bring bug-fixes , improvements - http://www.eclemma.org/jacoco/trunk/doc/changes.html
finally - seems tests located in separate module main code under test. "report" mojo creates report classes of current module. use "report-aggregate" aggregate coverage across modules - documentation can found @ http://www.eclemma.org/jacoco/trunk/doc/report-aggregate-mojo.html examples mentioned in https://groups.google.com/forum/#!msg/jacoco/8zjksseaxd4/qoux-ws-agaj
Comments
Post a Comment