如何测试片段场景测试中可见的矢量可绘制对象?

Lon*_*ger 7 android android-testing android-vectordrawable android-fragmentscenario

我编写了一些片段场景测试,这些测试将截取屏幕截图和一些点击事件。由于未显示图像视图,很少有测试失败。

测试库( https://developer.android.com/training/basics/fragments/testing )中的测试活动似乎使用 FragmentActivity,它不是 AppCompatActivity 的子类。结果,这些图像视图不可见。我可以添加属性android:src以使其在测试中可见,但这将是一个丑陋的修复。还有其他解决办法吗?

感谢对此的任何评论或建议。

view_item.xml

<ImageView
                android:id="@+id/ivRemove"
                android:layout_width="16dp"
                android:layout_height="16dp"
                android:layout_marginStart="@dimen/spacing_16dp"
                android:layout_marginTop="@dimen/spacing_16dp"
                android:layout_marginBottom="@dimen/spacing_16dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/ic_remove" />
Run Code Online (Sandbox Code Playgroud)

构建.gradle.kts

defaultConfig {
        this.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        this.vectorDrawables.useSupportLibrary = true
    }
Run Code Online (Sandbox Code Playgroud)