Skip to content

Commit

Permalink
Working to fix tests on TravisCI
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed Jan 20, 2020
1 parent b3cde0b commit 8a8dab8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
6 changes: 6 additions & 0 deletions omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,9 @@ jacocoAndroidUnitTestReport {
jacoco {
toolVersion = "0.7.5.201505241946"
}
test {
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.rule.GrantPermissionRule;
import it.feio.android.omninotes.db.DbHelper;
import it.feio.android.omninotes.utils.Constants;
Expand Down Expand Up @@ -50,14 +50,14 @@ public class BaseAndroidTestCase {

@BeforeClass
public static void setUpBeforeClass () {
testContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
testContext = ApplicationProvider.getApplicationContext();
prefs = testContext.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS);
dbHelper = DbHelper.getInstance(testContext);
prefs = testContext.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_PRIVATE);
// assertTrue("Database used for tests MUST not be the default one but prefixed by '" + DB_PREFIX + "'", dbHelper
// .getDatabase().getPath().matches(DB_PATH_REGEX));
assertFalse("Database MUST be writable", dbHelper.getDatabase().isReadOnly());
cleanDatabase();
// assertFalse("Database MUST be writable", dbHelper.getDatabase(true).isReadOnly());
// cleanDatabase();
}

@AfterClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package it.feio.android.omninotes.helpers;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.net.Uri;
import androidx.test.platform.app.InstrumentationRegistry;
Expand Down Expand Up @@ -62,7 +61,7 @@ public void setUp () throws Exception {
}

@Test
public void testExportNote () throws IOException {
public void exportNote () {
Note note = new Note();
note.setTitle("test title");
note.setContent("test content");
Expand All @@ -74,11 +73,11 @@ public void testExportNote () throws IOException {
TrueFileFilter.INSTANCE);
assertEquals(1, noteFiles.size());
Note retrievedNote = rx.Observable.from(noteFiles).map(BackupHelper::importNote).toBlocking().first();
assertTrue(note.equals(retrievedNote));
assertEquals(note, retrievedNote);
}

@Test
public void testExportNoteWithAttachment () throws IOException {
public void exportNoteWithAttachment () throws IOException {
Note note = new Note();
note.setTitle("test title");
note.setContent("test content");
Expand Down Expand Up @@ -106,7 +105,7 @@ public void testExportNoteWithAttachment () throws IOException {
}
}).toBlocking().first();
assertEquals(2, files.size());
assertTrue(note.equals(retrievedNote));
assertEquals(note, retrievedNote);
assertEquals(retrievedAttachmentContent, FileUtils.readFileToString(new File(attachment.getUri().getPath())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class LanguageHelperTest extends BaseAndroidTestCase {

@Test
public void shouldChangeSharedPrefrencesLanguage () {
public void changeSharedPrefrencesLanguage () {
LanguageHelper.updateLanguage(testContext, Locale.ITALY.toString());
SharedPreferences prefs = testContext.getSharedPreferences(Constants.PREFS_NAME, Context
.MODE_MULTI_PROCESS);
Expand All @@ -42,7 +42,7 @@ public void shouldChangeSharedPrefrencesLanguage () {
}

@Test
public void shouldChangeAppLanguage () {
public void changeAppLanguage () {
LanguageHelper.updateLanguage(testContext, Locale.ITALY.toString());
assertTranslationMatches(Locale.ITALY.toString(), R.string.add_note);
}
Expand Down

0 comments on commit 8a8dab8

Please sign in to comment.