From 2ddadb5a316b22a2760230acd76a22195fe08069 Mon Sep 17 00:00:00 2001 From: Rd Date: Tue, 7 Jan 2025 01:14:54 +0530 Subject: [PATCH] Fix Oppia Test Rule imports in few utility modules Needs //testing dependency and throws Fingerprint issues without RunWith AndroidJunit4 class. --- .../learneranalytics/ProfileAndDeviceIdFragmentTest.kt | 3 --- .../oppia/android/scripts/todo/TodoCollectorTest.kt | 3 --- .../android/util/logging/SyncStatusManagerImplTest.kt | 3 --- .../test/java/org/oppia/android/util/math/BUILD.bazel | 10 ++++++++++ .../ExpressionToComparableOperationConverterTest.kt | 3 --- .../org/oppia/android/util/math/FractionParserTest.kt | 3 --- .../android/util/math/MathExpressionExtensionsTest.kt | 3 --- .../android/util/math/MathExpressionParserTest.kt | 3 --- .../org/oppia/android/util/math/MathTokenizerTest.kt | 2 -- .../android/util/math/PolynomialExtensionsTest.kt | 3 --- .../org/oppia/android/util/math/RealExtensionsTest.kt | 3 --- .../java/org/oppia/android/util/networking/BUILD.bazel | 4 ++++ .../org/oppia/android/util/parser/math/BUILD.bazel | 1 + .../oppia/android/util/parser/math/MathModelTest.kt | 3 +++ 14 files changed, 18 insertions(+), 29 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt index 742fba83b67..1cab94e0265 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/administratorcontrols/learneranalytics/ProfileAndDeviceIdFragmentTest.kt @@ -781,10 +781,7 @@ class ProfileAndDeviceIdFragmentTest { } } - // req learner study analytics + log learner study id @Test - /*@EnableFeatureFlag("android_enable_logging_learner_study_ids") - @EnableFeatureFlag("android_enable_learner_study_analytics")*/ fun testFragment_multipleProfiles_clickShareIdsAndLogs_sendsIntentWithIdsAndLogsText() { // Use fake time so that the generated event logs are consistent across runs. fakeOppiaClock.setFakeTimeMode(FakeOppiaClock.FakeTimeMode.MODE_FIXED_FAKE_TIME) diff --git a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoCollectorTest.kt b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoCollectorTest.kt index af1199ff2ff..ab35976dfd2 100644 --- a/scripts/src/javatests/org/oppia/android/scripts/todo/TodoCollectorTest.kt +++ b/scripts/src/javatests/org/oppia/android/scripts/todo/TodoCollectorTest.kt @@ -9,9 +9,6 @@ import org.oppia.android.scripts.todo.model.Todo /** Tests for [TodoCollector]. */ class TodoCollectorTest { - @get:Rule - val oppiaTestRule = OppiaTestRule() - @field:[Rule JvmField] val tempFolder = TemporaryFolder() @Before diff --git a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt index c881de5601d..51f3bf13eac 100644 --- a/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt +++ b/utility/src/test/java/org/oppia/android/util/logging/SyncStatusManagerImplTest.kt @@ -39,9 +39,6 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = SyncStatusManagerImplTest.TestApplication::class) class SyncStatusManagerImplTest : SyncStatusManagerTestBase() { - @get:Rule - val oppiaTestRule = OppiaTestRule() - @Inject override lateinit var impl: SyncStatusManager @Inject override lateinit var monitorFactory: DataProviderTestMonitor.Factory @Inject override lateinit var persistentCacheStoreFactory: PersistentCacheStore.Factory diff --git a/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel index 7a59fa5612c..536799e3991 100644 --- a/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/math/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:math_equation_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", @@ -31,6 +32,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:math_expression_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", @@ -50,6 +52,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", @@ -68,6 +71,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:test_models", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", @@ -105,6 +109,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", "//third_party:com_google_truth_truth", @@ -124,6 +129,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:polynomial_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", @@ -142,6 +148,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", @@ -258,6 +265,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing:assertion_helpers", "//testing/src/main/java/org/oppia/android/testing/math:real_subject", "//third_party:androidx_test_ext_junit", @@ -277,6 +285,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//testing/src/main/java/org/oppia/android/testing/math:math_expression_subject", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_extensions_truth-liteproto-extension", @@ -333,6 +342,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//model/src/main/proto:math_java_proto_lite", + "//testing", "//third_party:androidx_test_ext_junit", "//third_party:com_google_truth_truth", "//third_party:junit_junit", diff --git a/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt b/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt index fd46205067c..4c1682f5ae2 100644 --- a/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/ExpressionToComparableOperationConverterTest.kt @@ -34,9 +34,6 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class ExpressionToComparableOperationConverterTest { - @get:Rule - val oppiaTestRule = OppiaTestRule() - @Parameter lateinit var op1: String @Parameter lateinit var op2: String diff --git a/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt index 33ce9d609f4..5126c6738c6 100644 --- a/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/FractionParserTest.kt @@ -19,9 +19,6 @@ import org.robolectric.annotation.LooperMode @LooperMode(LooperMode.Mode.PAUSED) @Config class FractionParserTest { - @get:Rule - val oppiaTestRule = OppiaTestRule() - private lateinit var fractionParser: FractionParser @Before diff --git a/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt index 216307067c3..dd5e3407aea 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathExpressionExtensionsTest.kt @@ -39,9 +39,6 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class MathExpressionExtensionsTest { - @get:Rule - val oppiaTestRule = OppiaTestRule() - @Parameter lateinit var exp1: String @Parameter lateinit var exp2: String diff --git a/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt index 850da372905..477f4b05078 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathExpressionParserTest.kt @@ -46,9 +46,6 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class MathExpressionParserTest { - @get:Rule - val oppiaTestRule = OppiaTestRule() - @Parameter lateinit var lhsOp: String @Parameter diff --git a/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt b/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt index bedddf6a222..aa6cbd79033 100644 --- a/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/MathTokenizerTest.kt @@ -20,8 +20,6 @@ import org.robolectric.annotation.LooperMode @SelectRunnerPlatform(ParameterizedJunitTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) class MathTokenizerTest { - @get:Rule - val oppiaTestRule = OppiaTestRule() @Parameter lateinit var variableName: String @Parameter lateinit var funcName: String diff --git a/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt index db894bbb45a..fbb56557822 100644 --- a/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/PolynomialExtensionsTest.kt @@ -131,9 +131,6 @@ class PolynomialExtensionsTest { ) } - @get:Rule - val oppiaTestRule = OppiaTestRule() - @Parameter lateinit var var1: String @Parameter lateinit var var2: String @Parameter lateinit var var3: String diff --git a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt index e9f33836411..f3cd9c28c8f 100644 --- a/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt +++ b/utility/src/test/java/org/oppia/android/util/math/RealExtensionsTest.kt @@ -81,9 +81,6 @@ class RealExtensionsTest { private val NEGATIVE_PI_REAL = createIrrationalReal(-PI) } - @get:Rule - val oppiaTestRule = OppiaTestRule() - private val fractionParser by lazy { FractionParser() } @Parameter var lhsInt: Int = Int.MIN_VALUE diff --git a/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel index c76aa778976..660c70f11f1 100644 --- a/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/networking/BUILD.bazel @@ -12,6 +12,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", @@ -34,6 +35,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", @@ -56,6 +58,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", @@ -78,6 +81,7 @@ oppia_android_test( test_manifest = "//utility:test_manifest", deps = [ "//:dagger", + "//testing", "//testing/src/main/java/org/oppia/android/testing/networking:network_connection_test_util", "//testing/src/main/java/org/oppia/android/testing/robolectric:test_module", "//testing/src/main/java/org/oppia/android/testing/time:test_module", diff --git a/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel b/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel index 3fb1fc751be..d693c47368b 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel +++ b/utility/src/test/java/org/oppia/android/util/parser/math/BUILD.bazel @@ -11,6 +11,7 @@ oppia_android_test( test_class = "org.oppia.android.util.parser.math.MathModelTest", test_manifest = "//utility:test_manifest", deps = [ + "//testing", "//third_party:com_google_truth_truth", "//third_party:junit_junit", "//third_party:robolectric_android-all", diff --git a/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt b/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt index 72f8a0f188e..681f40e4e27 100644 --- a/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt +++ b/utility/src/test/java/org/oppia/android/util/parser/math/MathModelTest.kt @@ -1,13 +1,16 @@ package org.oppia.android.util.parser.math +import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import org.junit.Rule import org.junit.Test +import org.junit.runner.RunWith import org.oppia.android.testing.OppiaTestRule import java.security.MessageDigest /** Tests for [MathModel]. */ // FunctionName: test names are conventionally named with underscores. +@RunWith(AndroidJUnit4::class) @Suppress("FunctionName") class MathModelTest { @get:Rule