add basic junit tests

This commit is contained in:
David Development 2015-01-18 00:04:51 +01:00
parent dfc4bf8616
commit 3f37932706
3 changed files with 78 additions and 0 deletions

View file

@ -0,0 +1,29 @@
package de.luhmer.owncloudnewsreader.junit_tests;
import org.junit.runners.model.InitializationError;
import org.robolectric.AndroidManifest;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.res.Fs;
public class RobolectricGradleTestRunner extends RobolectricTestRunner {
public RobolectricGradleTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
protected AndroidManifest getAppManifest(Config config) {
String myAppPath = RobolectricGradleTestRunner.class.getProtectionDomain()
.getCodeSource()
.getLocation()
.getPath();
String manifestPath = myAppPath + "../../../src/main/AndroidManifest.xml";
String resPath = myAppPath + "../../../src/main/res";
String assetPath = myAppPath + "../../../src/main/assets";
return createAppManifest(Fs.fileFromPath(manifestPath),
Fs.fileFromPath(resPath),
Fs.fileFromPath(assetPath));
}
}

View file

@ -0,0 +1,47 @@
package de.luhmer.owncloudnewsreader.junit_tests;
import android.database.Cursor;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.Stopwatch;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.annotation.Config;
import java.util.List;
import de.luhmer.owncloudnewsreader.NewsReaderListActivity;
import de.luhmer.owncloudnewsreader.database.DatabaseConnection;
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
import de.luhmer.owncloudnewsreader.database.DatabaseHelperOrm;
import de.luhmer.owncloudnewsreader.database.model.DaoSession;
import de.luhmer.owncloudnewsreader.database.model.Feed;
import static org.junit.Assert.*;
@Config(emulateSdk=18)
@RunWith(RobolectricGradleTestRunner.class)
public class TestDbTest {
private NewsReaderListActivity activity;
@Before
public void setup() {
activity = Robolectric.buildActivity(NewsReaderListActivity.class).create().get();
}
@Test
public void test() {
assertTrue(true);
}
/*
@Test
public void checkActivityNotNull() throws Exception {
assertNotNull(activity);
}
*/
}

View file

@ -0,0 +1,2 @@
# Robolectric doesn't know how to support SDK 19 yet.
emulateSdk=18