我正在尝试检查标题和描述textview的值是否与电影标题和描述相匹配,但这是我的第二个测试领域。请帮帮我
我的代码
@Test
fun test_isTitle_Description_Matches() {
val movie = INFINITY_WAR
val fragmentFactory = MovieFragmentFactory()
val bundle = Bundle()
bundle.putInt("movie_Id", movie.id)
val scenario = launchFragmentInContainer<MovieDetailFragment>()
onView(withId(R.id.movie_title)).check(matches(withText(movie.title)))
onView(withId(R.id.movie_description)).check(matches(withText(movie.description)))
}
您已经获得了捆绑软件和片段工厂,但没有传递给片段,请尝试下面的代码。
@Test
fun test_isTitle_Description_Matches() {
val movie = INFINITY_WAR
val fragmentFactory = MovieFragmentFactory()
val bundle = Bundle()
bundle.putInt("movie_Id", movie.id)
val scenario = launchFragmentInContainer<MovieDetailFragment>(
bundle,
fragmentFactory
)
onView(withId(R.id.movie_title)).check(matches(withText(movie.title)))
onView(withId(R.id.movie_description)).check(matches(withText(movie.description)))
}