Make sure that every Test class has at least one @Test method, or is abstract

This commit is contained in:
cpfeiffer 2016-09-04 22:52:55 +02:00
parent 411a90326e
commit 2e91246a45
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,7 @@
package nodomain.freeyourgadget.gadgetbridge.service.btle;
import org.junit.Test;
import nodomain.freeyourgadget.gadgetbridge.test.TestBase;
public class BtLEQueueTest extends TestBase {
@ -14,7 +16,8 @@ public class BtLEQueueTest extends TestBase {
}
@Test
public void testIsConnected() throws Exception {
// TODO
}
}

View File

@ -4,6 +4,7 @@ import android.database.sqlite.SQLiteDatabase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
@ -11,17 +12,18 @@ import org.robolectric.annotation.Config;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoMaster;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import static org.junit.Assert.assertNotNull;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
// need sdk 19 because "WITHOUT ROWID" is not supported in robolectric/sqlite4java
public class TestBase {
public abstract class TestBase {
protected GBApplication app = (GBApplication) RuntimeEnvironment.application;
protected DaoSession daoSession;
protected DBHandler dbHandler;
@ -29,12 +31,15 @@ public class TestBase {
@Before
public void setUp() throws Exception {
assertNotNull(app);
// doesn't work with Robolectric yet
// dbHandler = GBApplication.acquireDB();
// daoSession = dbHandler.getDaoSession();
DaoMaster.DevOpenHelper openHelper = new DaoMaster.DevOpenHelper(app, null, null);
SQLiteDatabase db = openHelper.getWritableDatabase();
daoSession = new DaoMaster(db).newSession();
assertNotNull(daoSession);
}
@After
@ -49,6 +54,4 @@ public class TestBase {
return dummyGBDevice;
}
}