5

Here's what I'm trying to run on Android 1.6:

package com.healthlogger.test;

public class AllTests extends TestSuite
{
    public static Test suite()
    {
        return new TestSuiteBuilder(AllTests.class).includeAllPackagesUnderHere().build();
    }
}

and:

package com.healthlogger.test;

public class RecordTest extends AndroidTestCase
{

    /**
     * Ensures that the constructor will not take a null data tag.
     */
    @Test(expected=AssertionFailedError.class)
    public void testNullDataTagInConstructor()
    {
        Record r = new Record(null, Calendar.getInstance(), "Data");
        fail("Failed to catch null data tag.");
    }
}

The main project is HealthLogger. These are run from a separate test project (HealthLoggerTest). HealthLogger and jUnit4 are in HealthLoggerTest's build path. jUnit4 is also in HealthLogger's build path. The class "Record" is located in com.healthlogger.

Commenting out the "@Test..." and "Record r..." lines allows this test to run. When they are uncommented, I get a VerifyError exception. I am severely blocked by this; why is it happening?


EDIT: some info from logcat after the crash:

    E/AndroidRuntime( 3723): Uncaught handler: thread main exiting due to uncaught exception                     
    E/AndroidRuntime( 3723): java.lang.VerifyError: com.healthlogger.test.RecordTest       E/AndroidRuntime( 3723): at java.lang.Class.getDeclaredConstructors(Native Method)
    E/AndroidRuntime( 3723): at java.lang.Class.getConstructors(Class.java:507) E/AndroidRuntime( 3723): at  android.test.suitebuilder.TestGrouping$TestCasePredicate.hasValidConstructor(TestGrouping.java:226) 

E/AndroidRuntime( 3723): at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:215)  

E/AndroidRuntime( 3723):    at android.test.suitebuilder.TestGrouping$TestCasePredicate.apply(TestGrouping.java:211) 

E/AndroidRuntime( 3723):        at android.test.suitebuilder.TestGrouping.select(TestGrouping.java:170) E/AndroidRuntime( 3723):        at android.test.suitebuilder.TestGrouping.selectTestClasses(TestGrouping.java:160) 

E/AndroidRuntime( 3723):        at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:154) 

E/AndroidRuntime( 3723):        at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:115) 

E/AndroidRuntime( 3723):        at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:103) 

E/AndroidRuntime( 3723):        at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:321) 

E/AndroidRuntime( 3723):        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3848) 

E/AndroidRuntime( 3723):        at android.app.ActivityThread.access$2800(ActivityThread.java:116) E/AndroidRuntime( 3723):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831) 

E/AndroidRuntime( 3723): at android.os.Handler.dispatchMessage(Handler.java:99) 

E/AndroidRuntime( 3723): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 3723):        at android.app.ActivityThread.main(ActivityThread.java:4203) 

E/AndroidRuntime( 3723): at java.lang.reflect.Method.invokeNative(Native Method) 

E/AndroidRuntime( 3723): at java.lang.reflect.Method.invoke(Method.java:521) 

E/AndroidRuntime( 3723): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) 

E/AndroidRuntime( 3723):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) E/AndroidRuntime( 3723):        at dalvik.system.NativeStart.main(Native Method)
3
  • possible duplicate of Android JUnit Tests failing with java.lang.VerifyError Commented Jul 2, 2011 at 22:13
  • You might be correct. Unfortunately, I can no longer try to verify a solution to this problem - I am without a 1.6 device. If you feel that the two are similar enough please feel free to delete / close this question. Commented Jul 4, 2011 at 16:11
  • Does it occur in the emulator? If so, you can try it on the 1.6 emulator. Commented Jul 21, 2011 at 15:02

1 Answer 1

0

This can occur when you forget to export all dependencies for a test project.

In Eclipse, go to the Java Build Path properties for your projects (both the main project and the test project). Go to the Organize/Export tab and make sure you check all dependencies (select all, except for any JRE or Classpath Container that might be listed).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.