Note that there are some explanatory texts on larger screens.

plurals
  1. POgreenDAO testSuiteConstructionFailed error when testing entities
    primarykey
    data
    text
    <p>I have tried writing test cases in JUnit using the greenDAO sample app as an example, but I get a RuntimeException caused by InvocationTargetException:</p> <p><img src="https://i.stack.imgur.com/lD6li.png" alt="JUnit error from greenDAO"></p> <p>It doesn't even run the tests.</p> <p>Below is the code that is barfing this up:</p> <pre><code>import de.greenrobot.dao.test.*; public class LibrarySummaryTest extends AbstractDaoTestLongPk&lt;LibrarySummaryDao, LibrarySummary&gt; { public LibrarySummaryTest() { super(LibrarySummaryDao.class); } @Override protected LibrarySummary createEntity(Long arg0) { // TODO Auto-generated method stub return null; } } </code></pre> <p>Is there something I am missing?</p> <p>I have an Android app, the tests are in a separate app. I indicated this when I generated the code:</p> <pre><code>schema.setDefaultJavaPackageTest("com.ralphpina.greenDao.test"); schema.setDefaultJavaPackageDao("com.ralphpina.greenDao.greendao"); </code></pre> <p>I have the instrumentation correctly targeting the app. I have a whole bunch of JUnit test cases that run perfectly fine.</p> <p>I have included the greenDAO.jar in both apps, and I have double checked that it is in the build path.</p> <p>I have the notes sample app in my eclipse environment and the JUnit test runs fine there. So there must be something specific in my project. Any suggestions?</p> <p>Text of full exception:</p> <pre><code>03-15 01:02:22.794: I/TestRunner(8775): java.lang.RuntimeException: Exception during suite construction 03-15 01:02:22.794: I/TestRunner(8775): at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238) 03-15 01:02:22.794: I/TestRunner(8775): at java.lang.reflect.Method.invokeNative(Native Method) 03-15 01:02:22.794: I/TestRunner(8775): at java.lang.reflect.Method.invoke(Method.java:511) 03-15 01:02:22.794: I/TestRunner(8775): at junit.framework.TestCase.runTest(TestCase.java:168) 03-15 01:02:22.794: I/TestRunner(8775): at junit.framework.TestCase.runBare(TestCase.java:134) 03-15 01:02:22.794: I/TestRunner(8775): at junit.framework.TestResult$1.protect(TestResult.java:115) 03-15 01:02:22.794: I/TestRunner(8775): at junit.framework.TestResult.runProtected(TestResult.java:133) 03-15 01:02:22.794: I/TestRunner(8775): at junit.framework.TestResult.run(TestResult.java:118) 03-15 01:02:22.794: I/TestRunner(8775): at junit.framework.TestCase.run(TestCase.java:124) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555) 03-15 01:02:22.794: I/TestRunner(8775): at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661) 03-15 01:02:22.794: I/TestRunner(8775): Caused by: java.lang.reflect.InvocationTargetException 03-15 01:02:22.794: I/TestRunner(8775): at java.lang.reflect.Constructor.constructNative(Native Method) 03-15 01:02:22.794: I/TestRunner(8775): at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:262) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:184) 03-15 01:02:22.794: I/TestRunner(8775): at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379) 03-15 01:02:22.794: I/TestRunner(8775): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4382) 03-15 01:02:22.794: I/TestRunner(8775): at android.app.ActivityThread.access$1300(ActivityThread.java:141) 03-15 01:02:22.794: I/TestRunner(8775): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1294) 03-15 01:02:22.794: I/TestRunner(8775): at android.os.Handler.dispatchMessage(Handler.java:99) 03-15 01:02:22.794: I/TestRunner(8775): at android.os.Looper.loop(Looper.java:137) 03-15 01:02:22.794: I/TestRunner(8775): at android.app.ActivityThread.main(ActivityThread.java:5039) 03-15 01:02:22.794: I/TestRunner(8775): at java.lang.reflect.Method.invokeNative(Native Method) 03-15 01:02:22.794: I/TestRunner(8775): at java.lang.reflect.Method.invoke(Method.java:511) 03-15 01:02:22.794: I/TestRunner(8775): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 03-15 01:02:22.794: I/TestRunner(8775): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 03-15 01:02:22.794: I/TestRunner(8775): at dalvik.system.NativeStart.main(Native Method) 03-15 01:02:22.794: I/TestRunner(8775): Caused by: java.lang.NoClassDefFoundError: com.outridersw.tapinspectandroid.greendao.DaoMaster 03-15 01:02:22.794: I/TestRunner(8775): at com.outridersw.tapinspectandroid.test.LibrarySummaryTest.&lt;init&gt;(LibrarySummaryTest.java:13) 03-15 01:02:22.794: I/TestRunner(8775): ... 18 more </code></pre> <p><strong>Update:</strong></p> <p>I was able to run JUnit by copying and pasting the generated classes in greenDAO into my test project. Obviously, this is not ideal, since now I have to remember to update them. Is there a reason JUnit can't find the greenDAO classes, but has no problems seeing all other classes in my target Android project?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload