dimanche 7 octobre 2018

test.R give me the wrong file

I'm trying to create a test that populates the DB with some test data. However, the SQL file I have in app\src\androidTest\res\raw comes back with the wrong file content.

It looks something like this. file content

But if I move the file to app\src\main\res\raw it works fine.

import com.package.test.R;

@Test
public void migrate1To2() throws IOException {
    SupportSQLiteDatabase db = helper.createDatabase(TEST_DB, 1);

    InputStream inputStream = InstrumentationRegistry.getTargetContext().getResources().openRawResource(R.raw.sql_test_data);

    String sqlQuery = IOUtils.toString(inputStream, "UTF-8");

    db.execSQL(sqlQuery);

    db.close();

    db = helper.runMigrationsAndValidate(TEST_DB, 2, true, MIGRATION_1_2);

    //Assert
}

What is going on and how do i fix this?

Aucun commentaire:

Enregistrer un commentaire