java.lang.NoClassDefFoundError: com_cenqua_clover.CoverageRecorder

maria rehman September 21, 2012

i am trying out clover on an android app in eclipse. i have a test app and a main app. when i try to run my function as clover it gives the following error.

junit.framework.AssertionFailedError: Exception in constructor: testDisplay (java.lang.NoClassDefFoundError: com_cenqua_clover.CoverageRecorder
at com.example.hello.test.helloWorldTest.<init>(helloWorldTest.java:24)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:118)
at android.test.AndroidTestRunner.getTest(AndroidTestRunner.java:148)
at android.test.AndroidTestRunner.setTestClassName(AndroidTestRunner.java:56)
at android.test.suitebuilder.TestSuiteBuilder.addTestClassByName(TestSuiteBuilder.java:80)
at android.test.InstrumentationTestRunner.parseTestClass(InstrumentationTestRunner.java:444)
at android.test.InstrumentationTestRunner.parseTestClasses(InstrumentationTestRunner.java:425)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:370)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4142)
at android.app.ActivityThread.access$1300(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1255)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1584)

2 answers

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 27, 2012

Currently we've got only Eclipse version available. If you believe that support for other tools (or command line) is necessary, feel free to vote on corresponding JIRA issues (link on Clover-for-Android page).

maria rehman September 27, 2012

Thank you very much for yours prompt reply. I will get back to you for additional inquires and questions.

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2012

Hi Maria,

Please make sure that:

  • you use Clover-for-Android instead of Clover-for-Eclipse
  • you export the "CLOVER_RUNTIME" library (in Project Properties > Java Build Path > Order and Export)

Regards
Marek

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2012

Please read the https://confluence.atlassian.com/display/CLOVER/Clover-for-Android

You cannot have default value of initstring. You must use "clover+remote:..." URI as described in manual above. You will also have to click "Referesh" button after tests in order to fetch coverage from Androd device (or emulator).

maria rehman September 23, 2012

Thank you Marek for your reply. i read through your forums did a clean build and now my clover is atleast showing no error.

But its still not showing any coverage. I am just seeing the pink lines which means no coverage. may be its my initString on both main and test app. both have default value enabled.

if this is incorrect please specify any link which gives more insight on how to configure the initstring for juint tests for android.

maria rehman September 23, 2012

ok so i just read through the tutorial. for my main app and the test app the nitString is .clover/coverage.db. This coverage.db is automatically created in the clover folder. In your tutorial it says not to use the same name of the.db file for both app and the test app. Do i need to create a new .db file with a separate name?
i tried to do that by naming it coverage-test.db but it generates an error.

ERROR: A problem was encountered while rendering the report: Clover registry file "C:\Users\marehman\workspace\helloTest\.clover\coverage-test.db" does not exist, cannot be read or is a directory.

Please ensure Clover has instrumented your source files.

You may need to remove existing .class files for this to occur.

please advice.
Thanks.

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 24, 2012

Do you mean that your initstring is ".clover/coverage.db"? It's necessary to use URI with absolute path; and make sure that "Relative to project dir" toggle is disabled. In your case:

C:\Users\marehman\workspace\helloTest\.clover\coverage-test.db

is would be:

clover+remote:file:///c%3A%5CUsers%5Cmarehman%5Cworkspace%5ChelloTest%5C.clover%5Ccoverage-test.db?localCoverageDir=/data/data/com.hello.test/clover

Regards
Marek

maria rehman September 27, 2012

okay so I am kind a confused about the InitString Setup. where is this /data/data/com is comming from? can you please specify how this InitString written.

One more question , Does clover works on android without eclipse? like on CLI or something?

Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 27, 2012

Hi Maria,

The initstring format is clearly described on the Clover-for-Android page. Please note that in case of application running on Android you do not copy clover.db to a device (and note that normally Clover requires this clover.db in runtime). So instead of using a simple path for initstring, you have to use URI in order to give Clover more information:

  • clover+remote - tell Clover to use special coverage recorder which does not require presence of clover.db at runtime
  • file:///path/to/clover.db - this is a location of clover.db on your desktop
  • ?localCoverageDir=/path/to/coverage/snapshot/dir - this is a location of coverage data files generated during application run on android device (or emulator); note that typical location where android app stores it's internal data is /data/data/<application name>/

Regards
Marek

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events