user1728732
user1728732

Reputation: 11

Robotium and Sherlock - NoClassDefFoundError

I've got problems with test in my project. I've got configured dependencies correctly but I can't run tests using Robotium. When my activity extends just Activity - everything is fine, when I add "extends SherlockActivity" then I got

java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238)

Caused by: java.lang.NoClassDefFoundError: com.calculator.Main (example project from Robotium www). 

I have tried to run test in Intellij and Eclipse. Both IDE gave same results.

Edit: It's my manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.calculator.test"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">

    <uses-library android:name="android.test.runner" />
    </application>
    <uses-sdk android:minSdkVersion="8" />
    <instrumentation android:targetPackage="com.calculator" android:name="android.test.InstrumentationTestRunner" />
</manifest> 

Upvotes: 1

Views: 539

Answers (2)

VISHAL VIRADIA
VISHAL VIRADIA

Reputation: 1418

it is not problem with any editor you used.

here is general syntax to start any activity from adb shell:

adb shell am start -a android.intent.action.MAIN -n com.package.name/com.package.name.ActivityName

So, when you call any activity from robotium it must " extends Activity ".

and " extends SherlockActivity " is not work with robotium because of above syntax required Activity name only. So if you extends any other thing it will not work.

Note :

[1] first try to open your activity with syntax bellow

adb shell am start -a android.intent.action.MAIN -n com.calculator/com.calculator.Main

here " Main " is activity in your package " com.calculator ".

[2] if this work for you then and then it will work for robotium.

i hope this concept will help you. thanks.

Upvotes: 0

Christian
Christian

Reputation: 14077

It looks like you compiled your class with correct dependencies but did not specify them at runtime. As both IntelliJ and Eclipse should use the same configuration for run like compile, the question is: how did you run the test?

Upvotes: 1

Related Questions