Skip to content
This repository

The Robolectric-SQLite project allows one to easily swap out the default H2 database for an SQLite database for use with Robolectric tests.

The @UsingDatabaseMap annotation and H2Map class are included in the main Robolectric project and the H2Map is used by default (whether you use the @UsingDatabaseMap annotation or not).

@UsingDatabaseMap(H2Map.class)
@RunWith(RobolectricTestRunner.class)
public class DaoTest {
    @Test
    public void RobolectricH2Test() {
    }
}

The Robolectric-SQLite project provides the SQLiteMap so one may use the SQLite database with Robolectric tests.

@UsingDatabaseMap(SQLiteMap.class)
@RunWith(RobolectricTestRunner.class)
public class DaoTest {
    @Test
    public void RobolectricSQLiteTest() {
    }
}

Robolectric-SQLite also provides a test suite that pulls all of the tests from the main Robolectric project to test SQLite against so you can be sure that Robolectric will work as expected when using SQLite.

Robolectric-SQLite requires at least version 1.0-RC5 of Robolectric and sqlite-jdbc-3.7.2.

sqlite-jdbc can be found in maven central:

<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.7.2</version>

Or downloaded directly from Xerial.org

Running Robolectric tests against Robolectric-SQLite

This requires that the robolectric and robolectric-sqlite folders are side-by-side in the filesystem (so they are siblings within their parent directory). And that the ANDROID_HOME environment variable is set. One also depends on robolectric-sqlite to have access to the robolectric-X.X-tests.jar

Something went wrong with that request. Please try again.