Open zcelaloglu opened 3 years ago
Hey @odaridavid, I'm working on fragment testing and getting an error related to permission that I found on stackoverflow
Installation failed due to: ''cmd package install-create -r -t --user current --full --dont-kill -t -g -S 1403340' returns error 'Unknown failure: Security exception: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag java.lang.SecurityException: You need the android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS permission to use the PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS flag
after I have found a meaningful answer on stackoverflow, I added necessary permission to manifest but it still complains
<uses-permission android:name="android.permission.INSTALL_GRANT_RUNTIME_PERMISSIONS"
tools:ignore="ProtectedPermissions" />
I also want to share all changes related to test cases:
navigation = '2.3.2'(upgrade from 2.2.2 in order to be able to use TestNavController)
fragmentTestVersion = '1.2.5'
fragmentTest : "androidx.fragment:fragment-testing:$fragmentTestVersion",
navigationTest : "androidx.navigation:navigation-testing:$navigation"
the first test case:
@Test
fun shouldDisplayDataOnSearch() {
val navController =
TestNavHostController(ApplicationProvider.getApplicationContext())
.apply { setGraph(R.navigation.nav_graph) }
launchFragmentInContainer<DashboardFragment>().onFragment {
Navigation.setViewNavController(it.requireView(), navController)
}
onView(withId(R.id.search_edit_text)).perform(typeText(EXISTING_SEARCH_PARAMS))
onView(withId(R.id.search_results_recycler_view)).check(matches(isDisplayed()))
}
Hmm ,I have no clue what this is about though adding permissions for the sake of testing doesn't seem right,I'll check out what you are trying to do and get more context
there is one more thing needs to be done before closing this PR is adding test cases for newly added fragment by using FragmentScenario
close #131