fix tests, add crashlitycs to .ignore

This commit is contained in:
Milos Kozak 2018-07-30 20:23:48 +02:00
parent 073b522b93
commit a590b1590a
6 changed files with 62 additions and 8 deletions

2
.gitignore vendored
View file

@ -11,3 +11,5 @@ app/src/main/jniLibs
full/ full/
debug/ debug/
release/ release/
app/com.crashlytics.settings.json
app/session_analytics.tap

View file

@ -4,17 +4,27 @@ import junit.framework.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import info.AAPSMocker;
import info.nightscout.androidaps.MainApp;
import info.nightscout.utils.SP;
/** /**
* Created by mike on 19.03.2018. * Created by mike on 19.03.2018.
*/ */
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({MainApp.class, SP.class})
public class ConstraintTest { public class ConstraintTest {
@Test @Test
public void doTests() throws Exception { public void doTests() {
AAPSMocker.mockMainApp();
AAPSMocker.mockApplicationContext();
AAPSMocker.mockSP();
Constraint<Boolean> b = new Constraint<>(true); Constraint<Boolean> b = new Constraint<>(true);
Assert.assertEquals(Boolean.TRUE, b.value()); Assert.assertEquals(Boolean.TRUE, b.value());
Assert.assertEquals("", b.getReasons()); Assert.assertEquals("", b.getReasons());

View file

@ -12,11 +12,12 @@ import org.powermock.modules.junit4.PowerMockRunner;
import info.AAPSMocker; import info.AAPSMocker;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.utils.SP;
import static org.powermock.api.mockito.PowerMockito.mock; import static org.powermock.api.mockito.PowerMockito.mock;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
@PrepareForTest({MainApp.class}) @PrepareForTest({MainApp.class, SP.class})
public class ConfigBuilderPluginTest { public class ConfigBuilderPluginTest {
@Test @Test
@ -41,9 +42,10 @@ public class ConfigBuilderPluginTest {
} }
@Before @Before
public void prepareMock() throws Exception { public void prepareMock() {
MainApp mainApp = mock(MainApp.class); AAPSMocker.mockMainApp();
PowerMockito.mockStatic(MainApp.class); AAPSMocker.mockApplicationContext();
AAPSMocker.mockSP();
AAPSMocker.prepareMockedBus(); AAPSMocker.prepareMockedBus();
} }

View file

@ -1,7 +1,18 @@
package info.nightscout.androidaps.plugins.PumpDanaRS.comm; package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
import android.content.Context;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import info.AAPSMocker;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -9,10 +20,15 @@ import static org.junit.Assert.assertEquals;
* Created by mike on 20.11.2017. * Created by mike on 20.11.2017.
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest({MainApp.class, SP.class})
public class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest extends DanaRS_Packet_APS_Basal_Set_Temporary_Basal { public class DanaRS_Packet_APS_Basal_Set_Temporary_BasalTest extends DanaRS_Packet_APS_Basal_Set_Temporary_Basal {
@Test @Test
public void runTest() throws Exception { public void runTest() {
AAPSMocker.mockMainApp();
AAPSMocker.mockApplicationContext();
AAPSMocker.mockSP();
// under 100% should last 30 min // under 100% should last 30 min
setParams(0); setParams(0);
assertEquals(0, temporaryBasalRatio); assertEquals(0, temporaryBasalRatio);

View file

@ -2,9 +2,15 @@ package info.nightscout.androidaps.plugins.PumpdanaRv2.comm;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import info.AAPSMocker;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_APS_Basal_Set_Temporary_Basal; import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_APS_Basal_Set_Temporary_Basal;
import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgSetAPSTempBasalStart_v2; import info.nightscout.androidaps.plugins.PumpDanaRv2.comm.MsgSetAPSTempBasalStart_v2;
import info.nightscout.utils.SP;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -12,10 +18,16 @@ import static org.junit.Assert.assertEquals;
* Created by mike on 20.11.2017. * Created by mike on 20.11.2017.
*/ */
@RunWith(PowerMockRunner.class)
@PrepareForTest({MainApp.class, SP.class})
public class MsgSetAPSTempBasalStart_v2Test extends MsgSetAPSTempBasalStart_v2 { public class MsgSetAPSTempBasalStart_v2Test extends MsgSetAPSTempBasalStart_v2 {
@Test @Test
public void runTest() throws Exception { public void runTest() {
AAPSMocker.mockMainApp();
AAPSMocker.mockApplicationContext();
AAPSMocker.mockSP();
// under 100% should last 30 min // under 100% should last 30 min
setParams(0); setParams(0);
assertEquals(0, intFromBuff(buffer, 0, 2)); assertEquals(0, intFromBuff(buffer, 0, 2));

View file

@ -1,13 +1,21 @@
package info.nightscout.androidaps.plugins.Sensitivity; package info.nightscout.androidaps.plugins.Sensitivity;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import info.AAPSMocker;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.utils.SP;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@RunWith(PowerMockRunner.class)
@PrepareForTest({MainApp.class, SP.class})
public class AbstractSensitivityPluginTest { public class AbstractSensitivityPluginTest {
private class SensitivityTestClass extends AbstractSensitivityPlugin { private class SensitivityTestClass extends AbstractSensitivityPlugin {
@ -28,6 +36,10 @@ public class AbstractSensitivityPluginTest {
@Test @Test
public void fillResultTest() { public void fillResultTest() {
AAPSMocker.mockMainApp();
AAPSMocker.mockApplicationContext();
AAPSMocker.mockSP();
SensitivityTestClass sut = new SensitivityTestClass(); SensitivityTestClass sut = new SensitivityTestClass();
AutosensResult ar = sut.fillResult(1d, 1d, "1", AutosensResult ar = sut.fillResult(1d, 1d, "1",