vmware-archive / AndroidIntelliJStarter

An IntelliJ template project for android developers, pre-configured to work with Robolectric, Roboguice, an other common, useful Android libraries.
MIT License
125 stars 39 forks source link

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

Open rvenugopal opened 11 years ago

rvenugopal commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

@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 commented 11 years ago

@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 commented 11 years ago

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 notifications@github.com 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/pivotal/AndroidIntelliJStarter/issues/4#issuecomment-16230460 .

mtholdefer commented 11 years ago

@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?