Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Roboelectric tests failing. Unable to resolve SQLite database connection #4

Open
rvenugopal opened this issue Feb 17, 2013 · 5 comments

Comments

@rvenugopal
Copy link

When I try the "Run tests" step from the instructions, a few tests fail which causes the build to fail

Run tests(step from the instructions) :

cd path_to_your_project_repo && (cd submodules/robolectric && ant clean findAndroidUnix && ant test) && ant clean test

The failing tests are
[junit] Test com.xtremelabs.robolectric.shadows.CursorAdapterTest FAILED
[junit] Test com.xtremelabs.robolectric.shadows.MergeCursorTest FAILED
[junit] Test com.xtremelabs.robolectric.shadows.SQLiteCursorTest FAILED
[junit] Test com.xtremelabs.robolectric.shadows.SQLiteDatabaseTest FAILED
[junit] Test com.xtremelabs.robolectric.shadows.SQLiteOpenHelperTest FAILED
[junit] Test com.xtremelabs.robolectric.shadows.SQLiteStatementTest FAILED

Looking at the reports, they all have a stack trace similar to the following

java.lang.NullPointerException
at org.sqlite.NestedDB$CausedSQLException.fillInStackTrace(NestedDB.java:649)
at java.lang.Throwable.(Throwable.java:250)
at java.lang.Exception.(Exception.java:54)
at java.sql.SQLException.(SQLException.java:140)
at org.sqlite.NestedDB$CausedSQLException.(NestedDB.java:626)
at org.sqlite.NestedDB._open(NestedDB.java:63)
at org.sqlite.DB.open(DB.java:86)
at org.sqlite.Conn.open(Conn.java:140)
at org.sqlite.Conn.(Conn.java:57)
at org.sqlite.JDBC.createConnection(JDBC.java:77)
at org.sqlite.JDBC.connect(JDBC.java:64)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:243)
at com.xtremelabs.robolectric.util.DatabaseConfig.getMemoryConnection(DatabaseConfig.java:69)
at com.xtremelabs.robolectric.shadows.CursorAdapterTest.setUp(CursorAdapterTest.java:38)
at com.xtremelabs.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:288)

It appears that database connection is not being resolved in DatabaseConfig.java (submodules/robolectric/src/main/java/com/xtremelabs/robolectric/util/DatabaseConfig.java)

Thanks
-Venu

@leviwilson
Copy link

I'm getting this same stack trace in one of my tests that is setting up a :memory: database. However, the same test passes in Eclipse when I run it, but not in ant.

@leviwilson
Copy link

@rvenugopal I found that the issue (for me anyway) was with Java 1.7 vs. 1.6. Running in Eclipse was fine, but this was because the unit test project was set to use the 1.6 compiler vs. my ant that was running 1.7. This post led me to this one, which talks about the incompatibility.

@rvenugopal
Copy link
Author

@leviwilson , thanks man. I will try it out.
However, I actually gave up on the AndroidIntellijStarter and went the route of Maven.
I had to use other libraries like RoboSherlock and trying to get that to work and manage its dependencies proved very time consuming. So I bit the bullet, learned Maven and got that working. I feel more confident that I can add more dependencies.

PS : I have not Open sourced it simply cause it is not a starter kit like this one, but just a working project.

@tylerschultz
Copy link
Contributor

FYI/FWIW - AndroidIntelliJStarter is now mavenized. Also, you may want to
check out something that Don Felker put together for bootstrapping android
projects (sorry I don't have the link handy).

On Thu, Apr 11, 2013 at 5:06 AM, Rao Venu [email protected] wrote:

@leviwilson https://github.com/leviwilson , thanks man. I will try it
out.
However, I actually gave up on the AndroidIntellijStarter and went the
route of Maven.
I had to use other libraries like RoboSherlock and trying to get that to
work and manage its dependencies proved very time consuming. So I bit the
bullet, learned Maven and got that working. I feel more confident that I
can add more dependencies.

PS : I have not Open sourced it simply cause it is not a starter kit like
this one, but just a working project.


Reply to this email directly or view it on GitHubhttps://github.com//issues/4#issuecomment-16230460
.

@mtholdefer
Copy link

@leviwilson I am getting this same stack trace when I am trying to run any tests that use a SQLite database in eclipse. The tests, however, will work when their test class is run individually, but when i try to run all the tests in the project the tests fail. Why would they work individually but not in a group?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants