我有問題需要在ITALIC風格中測試顯示單詞。有人可以提供我任何示例代碼來顯示文字風格嗎?我在android studio中使用Espresso和JUnit 4。我非常感謝你的合作。謝謝如何在濃縮咖啡測試中測試單詞風格「ITALIC」
0
A
回答
0
這應該使你的TextView
大膽,同時強調和斜體。
的strings.xml
<resources>
<string name="register"><u><b><i>Copyright</i></b></u></string>
</resources>
要設置該字符串到您的TextView的,在你的main.xml中做到這一點
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/register" />
+0
是的。我已經有這個。現在,我想在使用Android Studio的測試自動化中測試ITALIC WORD – intan
0
請嘗試以下解。它可能適合你。 核心思想是考慮爲您的情況使用自定義的ViewMatcher。
public static Matcher<View> withItalicStyle(final int resourceId) {
return new TypeSafeMatcher<View>() {
@Override
public void describeTo(Description description) {
description.appendText("has Italic Text with resource");
}
@Override
public boolean matchesSafely(View view) {
TextView textView = (TextView) view.findViewById(resourceId);
return (textView.getTypeface().getStyle() == Typeface.ITALIC);
}
};
}
而且在你的測試用例,你可以
onView(CustomMatchers.withItalicStyle(R.id.yourResourceId)).check(isDisplayed());
+1
您可以避免使用[BoundedMatcher]進行投射(https://developer.android.com/reference/android/support/test/espresso/matcher/BoundedMatcher.html ) –
相關問題
- 1. 多次運行濃縮咖啡測試
- 2. 意式濃縮咖啡測試 - Android
- 3. 濃縮咖啡循環結束測試
- 4. 如何在濃縮咖啡測試中循環3個按鈕
- 5. 隨機濃咖啡測試失敗
- 6. 測試片段與濃咖啡庫
- 7. CircleCI上的濃咖啡測試失敗
- 8. 勺子和濃咖啡測試
- 9. Android如何通過濃縮咖啡測試失敗
- 10. 勺子:在濃縮咖啡測試中的空白adb日誌
- 11. 在控制檯上顯示濃縮咖啡測試結果
- 12. 如何反覆運行單元測試+濃咖啡?
- 13. 使用濃縮咖啡測試可繪製的變化
- 14. 濃縮咖啡,測試登錄屏幕的快樂路徑
- 15. 使用Dagger2進行濃縮咖啡測試
- 16. 意式濃縮咖啡測試不更新
- 17. 意式濃縮咖啡測試與永不落幕AsyncTask
- 18. 濃縮咖啡和手動同時測試
- 19. 意式濃縮咖啡嵌套回收器視圖UI測試
- 20. 濃縮咖啡測試不能處理挑選者
- 21. 濃縮咖啡測試ImageView包含可繪製
- 22. 使用ExpandableListView進行濃縮咖啡測試
- 23. 使用濃咖啡測試Android NavigationView菜單項
- 24. 如何更改設備上的IME以進行濃縮咖啡測試
- 25. 濃咖啡測試中的Apache Poi 64K錯誤
- 26. 在android工作室的濃咖啡測試
- 27. AndroidStudio記錄咖啡測試
- 28. 拖放濃縮咖啡
- 29. 安卓意式濃縮咖啡讓應用程序在測試後運行
- 30. 如何測試與RxBindings和咖啡
使用'機器人:TEXTSTYLE = 「斜體」'。 – KeLiuyue
@KeLiuyue ..謝謝。但是如何在Test Automation內部進行測試。 – intan