Logging in tests
This commit is contained in:
parent
416f5b7cab
commit
7e6501bded
|
@ -0,0 +1,60 @@
|
|||
package info.nightscout.androidaps.logging
|
||||
|
||||
/**
|
||||
* Created by adrian on 2019-12-27.
|
||||
*/
|
||||
|
||||
class AAPSLoggerTest : AAPSLogger {
|
||||
|
||||
override fun debug(message: String) {
|
||||
println("DEBUG: $message")
|
||||
}
|
||||
|
||||
override fun debug(enable: Boolean, tag: LTag, message: String) {
|
||||
println("DEBUG: " + message)
|
||||
}
|
||||
|
||||
override fun debug(tag: LTag, message: String) {
|
||||
println("DEBUG: : " + tag.tag + " " + message)
|
||||
}
|
||||
|
||||
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
println("DEBUG: : " + tag.tag + " " + String.format(format, arguments))
|
||||
}
|
||||
|
||||
override fun warn(tag: LTag, message: String) {
|
||||
println("WARN: " + tag.tag + " " + message)
|
||||
}
|
||||
|
||||
override fun info(tag: LTag, message: String) {
|
||||
println("INFO: " + tag.tag + " " + message)
|
||||
}
|
||||
|
||||
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
println("INFO: : " + tag.tag + " " + String.format(format, arguments))
|
||||
}
|
||||
|
||||
override fun error(tag: LTag, message: String) {
|
||||
println("ERROR: " + tag.tag + " " + message)
|
||||
}
|
||||
|
||||
override fun error(message: String) {
|
||||
println("ERROR: " + message)
|
||||
}
|
||||
|
||||
override fun error(message: String, throwable: Throwable) {
|
||||
println("ERROR: " + message + " " + throwable)
|
||||
}
|
||||
|
||||
override fun error(format: String, vararg arguments: Any?) {
|
||||
println("ERROR: : " + String.format(format, arguments))
|
||||
}
|
||||
|
||||
override fun error(tag: LTag, message: String, throwable: Throwable) {
|
||||
println("ERROR: " + tag.tag + " " + message + " " + throwable)
|
||||
}
|
||||
|
||||
override fun error(tag: LTag, format: String, vararg arguments: Any?) {
|
||||
println("ERROR: : " + tag.tag + " " + String.format(format, arguments))
|
||||
}
|
||||
}
|
|
@ -1,30 +1,30 @@
|
|||
package info.nightscout.androidaps.logging
|
||||
|
||||
enum class LTag(val tag: String, val defaultValue : Boolean = false, val requiresRestart: Boolean = false) {
|
||||
CORE("CORE", defaultValue = false),
|
||||
APS("APS", defaultValue = false),
|
||||
AUTOSENS("AUTOSENS"),
|
||||
AUTOMATION("AUTOMATION", defaultValue = false),
|
||||
BGSOURCE("BGSOURCE", defaultValue = false),
|
||||
enum class LTag(val tag: String, val defaultValue : Boolean = true, val requiresRestart: Boolean = false) {
|
||||
CORE("CORE"),
|
||||
APS("APS"),
|
||||
AUTOSENS("AUTOSENS", defaultValue = false),
|
||||
AUTOMATION("AUTOMATION"),
|
||||
BGSOURCE("BGSOURCE"),
|
||||
CONFIGBUILDER("CONFIGBUILDER"),
|
||||
CONSTRAINTS("CONSTRAINTS", defaultValue = false),
|
||||
DATABASE("DATABASE", defaultValue = false),
|
||||
DATAFOOD("DATAFOOD"),
|
||||
DATASERVICE("DATASERVICE", defaultValue = false),
|
||||
DATATREATMENTS("DATATREATMENTS", defaultValue = false),
|
||||
CONSTRAINTS("CONSTRAINTS"),
|
||||
DATABASE("DATABASE"),
|
||||
DATAFOOD("DATAFOOD", defaultValue = false),
|
||||
DATASERVICE("DATASERVICE"),
|
||||
DATATREATMENTS("DATATREATMENTS"),
|
||||
EVENTS("EVENTS", defaultValue = false, requiresRestart = true),
|
||||
GLUCOSE("GLUCOSE"),
|
||||
LOCATION("LOCATION", defaultValue = false),
|
||||
NOTIFICATION("NOTIFICATION", defaultValue = false),
|
||||
NSCLIENT("NSCLIENT", defaultValue = false),
|
||||
LOCATION("LOCATION"),
|
||||
NOTIFICATION("NOTIFICATION"),
|
||||
NSCLIENT("NSCLIENT"),
|
||||
OVERVIEW("OVERVIEW", defaultValue = false),
|
||||
PUMP("PUMP", defaultValue = false),
|
||||
PUMPBTCOMM("PUMPBTCOMM"),
|
||||
PUMPCOMM("PUMPCOMM", defaultValue = false),
|
||||
PUMPQUEUE("PUMPQUEUE", defaultValue = false),
|
||||
PROFILE("PROFILE", defaultValue = false),
|
||||
SMS("SMS", defaultValue = false),
|
||||
PUMP("PUMP"),
|
||||
PUMPBTCOMM("PUMPBTCOMM", defaultValue = false),
|
||||
PUMPCOMM("PUMPCOMM"),
|
||||
PUMPQUEUE("PUMPQUEUE"),
|
||||
PROFILE("PROFILE"),
|
||||
SMS("SMS"),
|
||||
TIDEPOOL("TIDEPOOL"),
|
||||
UI("UI", defaultValue = false),
|
||||
WEAR("WEAR")
|
||||
WEAR("WEAR", defaultValue = false)
|
||||
}
|
|
@ -4,6 +4,7 @@ import dagger.android.AndroidInjector
|
|||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.data.ProfileStore
|
||||
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
||||
import org.json.JSONObject
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
|
@ -13,6 +14,9 @@ import org.mockito.junit.MockitoRule
|
|||
import java.util.*
|
||||
|
||||
open class TestBase {
|
||||
|
||||
val aapsLogger = AAPSLoggerTest()
|
||||
|
||||
// Add a JUnit rule that will setup the @Mock annotated vars and log.
|
||||
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
|
||||
@get:Rule
|
||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.data.ProfileStore
|
|||
import info.nightscout.androidaps.db.ProfileSwitch
|
||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.AAPSLoggerTest
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
|
@ -18,7 +19,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
|||
|
||||
@PrepareForTest(FabricPrivacy::class)
|
||||
open class TestBaseWithProfile : TestBase() {
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var activePluginProvider: ActivePluginProvider
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(Profile::class)
|
||||
class QuickWizardTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.logging.Logger
|
|||
@PrepareForTest(MainApp::class, Logger::class, L::class, SP::class, GlucoseStatus::class)
|
||||
class BgReadingTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -19,8 +19,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(MainApp::class, SP::class)
|
||||
class ConstraintTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
@Test fun doTests() {
|
||||
val b = Constraint(true)
|
||||
Assert.assertEquals(true, b.value())
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(ConstraintChecker::class, VirtualPumpPlugin::class)
|
||||
class LoopPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var sp: SP
|
||||
private val rxBus: RxBusWrapper = RxBusWrapper()
|
||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
|
|
|
@ -25,7 +25,6 @@ class ConfigBuilderPluginTest : TestBase() {
|
|||
@Mock lateinit var treatmentsPlugin: Lazy<TreatmentsPlugin>
|
||||
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var commandQueue: CommandQueueProvider
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.*
|
|||
@RunWith(PowerMockRunner::class)
|
||||
class DstHelperPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@RunWith(PowerMockRunner::class)
|
||||
class ObjectivesPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var activePlugin: ActivePluginProvider
|
||||
@Mock lateinit var sp: SP
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.junit.Test
|
|||
import org.mockito.Mock
|
||||
|
||||
class SignatureVerifierPluginTest : TestBase() {
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var context: Context
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@RunWith(PowerMockRunner::class)
|
||||
class StorageConstraintPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
private val rxBusWrapper = RxBusWrapper()
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ class VersionCheckerUtilsKtTest : TestBase() {
|
|||
|
||||
lateinit var versionCheckerUtils: VersionCheckerUtils
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var context: Context
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@RunWith(PowerMockRunner::class)
|
||||
class AutomationEventTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var loopPlugin: LoopPlugin
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(NSUpload::class, RxBusWrapper::class)
|
||||
class ActionNotificationTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var rxBus: RxBusWrapper
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ class MaintenancePluginTest : TestBase() {
|
|||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var nsSettingsStatus: NSSettingsStatus
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var buildHelper: BuildHelper
|
||||
|
||||
lateinit var sut: MaintenancePlugin
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(MainApp::class, SP::class, Context::class)
|
||||
class NsClientReceiverDelegateTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var context: Context
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(SmsCommunicatorPlugin::class, DateUtil::class, OneTimePassword::class)
|
||||
class AuthRequestTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var otp: OneTimePassword
|
||||
|
|
|
@ -30,7 +30,6 @@ class InsulinOrefFreePeakPluginTest : TestBase() {
|
|||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var rxBus: RxBusWrapper
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
private var injector: HasAndroidInjector = HasAndroidInjector {
|
||||
AndroidInjector {
|
||||
|
|
|
@ -30,7 +30,6 @@ import java.util.*
|
|||
@PrepareForTest(IobCobCalculatorPlugin::class, DateUtil::class)
|
||||
class GlucoseStatusTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
||||
|
||||
val injector = HasAndroidInjector {
|
||||
|
|
|
@ -32,7 +32,6 @@ import java.util.*
|
|||
@PrepareForTest(FabricPrivacy::class)
|
||||
class IobCobCalculatorPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var sp: SP
|
||||
private val rxBus: RxBusWrapper = RxBusWrapper()
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(MainApp::class, ConfigBuilderPlugin::class, ConstraintChecker::class, Context::class, CommandQueue::class)
|
||||
class ComboPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
|
|
|
@ -14,8 +14,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@RunWith(PowerMockRunner::class)
|
||||
class DetailedBolusInfoStorageTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
private val info1 = DetailedBolusInfo()
|
||||
private val info2 = DetailedBolusInfo()
|
||||
private val info3 = DetailedBolusInfo()
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.mockito.Mock
|
|||
|
||||
open class DanaRTestBase : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var injector: HasAndroidInjector
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
@PrepareForTest(FabricPrivacy::class)
|
||||
class VirtualPumpPluginUTest : TestBase() {
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
val rxBus = RxBusWrapper()
|
||||
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
class AbstractSensitivityPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var pluginDescription: PluginDescription
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.mockito.Mock
|
|||
class GlimpPluginTest : TestBase() {
|
||||
private lateinit var glimpPlugin: GlimpPlugin
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Before
|
||||
|
|
|
@ -17,7 +17,6 @@ class MM640GPluginTest : TestBase() {
|
|||
|
||||
private lateinit var mM640gPlugin: MM640gPlugin
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Before
|
||||
|
|
|
@ -18,7 +18,6 @@ class NSClientPluginTest : TestBase() {
|
|||
|
||||
private lateinit var nsClientSourcePlugin: NSClientSourcePlugin
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ class XdripPluginTest : TestBase() {
|
|||
|
||||
private lateinit var xdripPlugin: XdripPlugin
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Before
|
||||
|
|
|
@ -37,7 +37,6 @@ class BolusWizardTest : TestBase() {
|
|||
|
||||
private val PUMP_BOLUS_STEP = 0.1
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var constraintChecker: ConstraintChecker
|
||||
|
|
Loading…
Reference in a new issue