-
Notifications
You must be signed in to change notification settings - Fork 545
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
Fix #3103: Segregate OptionsFragment tests #3114
Fix #3103: Segregate OptionsFragment tests #3114
Conversation
@rt4914
Will proceed to Part-B of the issue after getting an initial pass on Part-A. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are failing on Roboelectric.
Each test should pass on Roboelectric as well as Espresso. Also make sure that CI checks also pass.
app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt
Outdated
Show resolved
Hide resolved
Apologies! will remember to check each of them before making a commit. |
@Sparsh1212 I will review this tomorrow but meanwhile you can move to part B too. |
@rt4914
@Test
fun testApp_Language_pressBackBtn_SendsBackCorrectInfo(){
launch<AppLanguageActivity>(createAppLanguageActivityIntent("English")).use {
testCoroutineDispatchers.runCurrent()
pressBack()
intended(hasExtra(MESSAGE_APP_LANGUAGE_ARGUMENT_KEY, "English"))
}
} But it is failing in Roboelectric with the error that 0 intends matched.
Thanks! |
@Sparsh1212 Have you checked ShadowActivity? https://stackoverflow.com/a/8991026 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
regarding the testApp_Language_pressBackBtn_SendsBackCorrectInfo
, we cannot use ShadowActivity, this will make this test robolectric only.
The reason, I am seeing here why the test fails is:
override fun onBackPressed() {
val message = appLanguageActivityPresenter.getLanguageSelected()
val intent = Intent()
intent.putExtra(MESSAGE_APP_LANGUAGE_ARGUMENT_KEY, message)
setResult(REQUEST_CODE_APP_LANGUAGE, intent)
finish()
}
on back press, the activity gets finish, so test is basically trying to test after activity gets finished.
I don't think this test will pass on espresso also. This test seems like to come under e2e test.
Also, add all the espresso test result screenshots in PR description.
app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/sharedTest/java/org/oppia/android/app/options/OptionsFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/test/java/org/oppia/android/app/testing/options/AppLanguageFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/test/java/org/oppia/android/app/testing/options/AppLanguageFragmentTest.kt
Outdated
Show resolved
Hide resolved
app/src/test/java/org/oppia/android/app/testing/options/AppLanguageFragmentTest.kt
Show resolved
Hide resolved
Thanks, will update and make all the suggested changes. |
Un-assigning until @anandwana001 approves it. |
Added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks @Sparsh1212
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sparsh1212 Replied to my one of the open comments.
"READING_TEXT_SIZE_PREFERENCE_SUMMARY_VALUE" | ||
const val APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY = | ||
"AppLanguageActivity.app_language_preference_summary_value" | ||
const val KEY_AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you have removed it from test file. But instead what we want it we should either use only
const val MESSAGE_READING_TEXT_SIZE_ARGUMENT_KEY = "OptionsFragment.message_reading_text_size"
const val MESSAGE_APP_LANGUAGE_ARGUMENT_KEY = "OptionsFragment.message_app_language"
const val MESSAGE_AUDIO_LANGUAGE_ARGUMENT_KEY = "OptionsFragment.message_audio_language"
in tests and production code
or we should use only
const val KEY_READING_TEXT_SIZE_PREFERENCE_SUMMARY_VALUE =
"READING_TEXT_SIZE_PREFERENCE_SUMMARY_VALUE"
const val APP_LANGUAGE_PREFERENCE_SUMMARY_VALUE_EXTRA_KEY =
"AppLanguageActivity.app_language_preference_summary_value"
const val KEY_AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE =
"AUDIO_LANGUAGE_PREFERENCE_SUMMARY_VALUE"
Currently you are using the above for the app layer code and the below for test cases which is incorrect. We should use only one of these sets in both code.
…-tests"" This reverts commit 91b886a.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
Unfortunately we cannot merge this until #3157 is fixed.
@rt4914 I have taken the pull from the latest develop branch. The checks are also passing. Looks like we can merge this now :) |
Explanation
Fixes #3103: Tests Segregation in OptionsFragmentTest
Espresso Test results snapshots:
Checklist