Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RunAllTests] Consolidate testing to ensure all tests are covered in Bazel CI #2697

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
471 changes: 28 additions & 443 deletions app/BUILD.bazel

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions app/app_test.bzl
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
load("//:oppia_android_test.bzl", "oppia_android_test")
load("//:oppia_android_test.bzl", "oppia_android_module_level_test")

# TODO(#1620): Remove module-specific test macros once Gradle is removed
def app_test(name, srcs, test_class, deps, **kwargs):
'''
def app_test(name, processed_src, test_path_prefix, filtered_tests, deps, **kwargs):
"""
Creates individual tests for test files in the app module.

Args:
name: str. The name of the Kotlin test file without the '.kt' suffix.
src: list of str. The list of test files to be run.
test_class: str. The package of the src file. Example: If the src is 'FakeEventLoggerTest.kt',
then the test_class would be "org.oppia.testing.FakeEventLoggerTest".
name: str. The relative path to the Kotlin test file.
processed_src: str. The source to a processed version of the test that should be used
instead of the original.
test_path_prefix: str. The prefix of the test path (which is used to extract the qualified
class name of the test suite).
filtered_tests: list of str. The test files that should not have tests defined for them.
deps: list of str. The list of dependencies needed to build and run this test.
'''

oppia_android_test(
"""
oppia_android_module_level_test(
name = name,
srcs = srcs + ["src/test/java/DataBinderMapperImpl.java"],
processed_src = processed_src,
filtered_tests = filtered_tests,
test_path_prefix = test_path_prefix,
deps = deps,
custom_package = "org.oppia.android.app.test",
test_class = test_class,
test_manifest = "src/test/AndroidManifest.xml",
deps = deps,
additional_srcs = ["src/test/java/DataBinderMapperImpl.java"],
enable_data_binding = True,
**kwargs
)
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ import org.robolectric.annotation.LooperMode
import javax.inject.Inject
import javax.inject.Singleton

private const val KEY_READING_TEXT_SIZE_PREFERENCE_TITLE = "READING_TEXT_SIZE_PREFERENCE"
private const val APP_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY =
"AppLanguageActivity.app_language_preference_title"
private const val KEY_AUDIO_LANGUAGE_PREFERENCE_TITLE = "AUDIO_LANGUAGE_PREFERENCE"

@RunWith(AndroidJUnit4::class)
@Config(application = OptionsFragmentTest.TestApplication::class)
class OptionsFragmentTest {
Expand Down Expand Up @@ -112,12 +117,7 @@ class OptionsFragmentTest {
click()
)
intended(hasComponent(ReadingTextSizeActivity::class.java.name))
intended(
hasExtra(
ReadingTextSizeActivity.KEY_READING_TEXT_SIZE_PREFERENCE_TITLE,
READING_TEXT_SIZE
)
)
intended(hasExtra(KEY_READING_TEXT_SIZE_PREFERENCE_TITLE, READING_TEXT_SIZE))
}
}

Expand All @@ -135,12 +135,7 @@ class OptionsFragmentTest {
click()
)
intended(hasComponent(AppLanguageActivity::class.java.name))
intended(
hasExtra(
AppLanguageActivity.APP_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY,
APP_LANGUAGE
)
)
intended(hasExtra(APP_LANGUAGE_PREFERENCE_TITLE_EXTRA_KEY, APP_LANGUAGE))
}
}

Expand All @@ -158,12 +153,7 @@ class OptionsFragmentTest {
click()
)
intended(hasComponent(AudioLanguageActivity::class.java.name))
intended(
hasExtra(
AudioLanguageActivity.KEY_AUDIO_LANGUAGE_PREFERENCE_TITLE,
AUDIO_LANGUAGE
)
)
intended(hasExtra(KEY_AUDIO_LANGUAGE_PREFERENCE_TITLE, AUDIO_LANGUAGE))
}
}

Expand Down
Loading