robolectric / robolectric

Android Unit Testing Framework
http://robolectric.org
Other
5.8k stars 1.36k forks source link

SQLiteDatabase test issues #23

Closed billmccord closed 13 years ago

billmccord commented 13 years ago

I am trying to use your code with SQLite, but the tests are failing because in the CREATE TABLE statement on line 32 of SQLiteDatabaseTest you are using AUTO_INCREMENT instead of AUTOINCREMENT. Also, SQLite doesn't like INT instead of INTEGER.

Since you said you planned to support configuring between different databases, I thought you might want to know.

i.e. statement.execute("CREATE TABLE table_name (id INT PRIMARY KEY AUTO_INCREMENT, first_column VARCHAR(255), second_column BINARY, name VARCHAR(255));");

should be: statement.execute("CREATE TABLE table_name (id INTEGER PRIMARY KEY AUTOINCREMENT, first_column VARCHAR(255), second_column BINARY, name VARCHAR(255));");

billmccord commented 13 years ago

The issues run deeper than this. Apparently, h2 doesn't support the same syntax as SQLite for CREATE TABLE, so you are going to have problems if you try to use your tests in their current form for a real SQLite database.

Also, the SQLite Java implementation I'm using also doesn't support in-memory writing, so all of the tests fail now because it tries to CREATE TABLE table_name in the setup of each test, but doesn't DROP TABLE table_name anywhere and therefore fails because it is trying to create the same table over and over...

billmccord commented 13 years ago

And even more issues because SQLite only supports JDBC ResultSet TYPE_FORWARD_ONLY. Also, it seems a lot of the work that you guys are doing to make h2 work is causing SQLite statements to break. This is unfortunate and I don't fully understand the logic in hacking h2 to work when Android uses SQLite. The binary concern is valid, but if you use the library I pointed to, it is "100% Pure Java driver based on NestedVM emulation."

Anyway, I don't have the bandwidth to roll my own, so I am going to use your h2 stuff for now. Thanks guys for creating this project, it helps me a lot.