Emma Reports 0% Coverage
Solution 1:
I ran into the same issue and I think I understand what happened here.
I looks like the sources of the package under test were also inside (or referenced as being sources) of the test package.
The result is that your package apks looked like the following if you opened them up:
PackageUnderTest/ClassFileUnderTest
TestPackage/TestClass
TestPackage/ClassFileUnderTest
ClassFileUnderTest:
pluclic classClassFileUnderTest{
publicintfoo(){
...
}
}
TestClass:
pluclic classTestClass{
publicvoidtestFoo(){
int result = foo();
assert...
}
}
What is happening here is that whenever your TestClass called the foo() method from testFoo(), foo() got called on TestClass/ClassFileUnderTest instead of PackageUnderTest/ClassFileUnderTest.
As a result, the instumented PackageUnderTest/ClassFileUnderTest never got run and didn't get tallied in the coverage report.
Removing the reference PackageUnderTest code from the TestPackage enforced that the PackageUnderTest code got run from PackageUnderTest and tallied into the coverage report.
Solution 2:
Finally, after many hours of fighting, question resolved. Resolution is very simple and unexpectable.
In build.properties of the TEST project I had something like:
tested.project.dir=..
env.WORKSPACE= /bla/bla
source.dir=${env.WORKSPACE}/first/src;${env.WORKSPACE}/second/src;${env.WORKSPACE}/andsoon/src;
But! I should NOT specify source.dir here! Specifying tested.project.dir
is enough to compile test project successfully.
Moreover, if I specify source.dir in TEST project like this - tests run well but emma reports zero coverage, just as stated in question.
Post a Comment for "Emma Reports 0% Coverage"