Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “如何测试单词风格”;斜体字;在浓缩咖啡测试中_Java_Android_Junit4_Android Espresso_Italic - Fatal编程技术网

Java “如何测试单词风格”;斜体字;在浓缩咖啡测试中

Java “如何测试单词风格”;斜体字;在浓缩咖啡测试中,java,android,junit4,android-espresso,italic,Java,Android,Junit4,Android Espresso,Italic,我在测试斜体显示单词时遇到问题。有人能给我提供一些示例代码来显示单词样式吗?我正在android studio中使用浓缩咖啡和JUnit4。我真的很感谢你的合作。谢谢请尝试以下解决方案。这可能对你有用。 核心思想是考虑为您的案例使用自定义ViewMatcher public static Matcher<View> withItalicStyle(final int resourceId) { return new TypeSafeMatcher<View>()

我在测试斜体显示单词时遇到问题。有人能给我提供一些示例代码来显示单词样式吗?我正在android studio中使用浓缩咖啡和JUnit4。我真的很感谢你的合作。谢谢

请尝试以下解决方案。这可能对你有用。 核心思想是考虑为您的案例使用自定义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);
        }
    };
}

对于教程,请检查使用
android:textStyle=“italic”
@KeLiuyue.中的谷歌示例。。非常感谢。但如何测试内部测试自动化。您可以避免使用
    onView(CustomMatchers.withItalicStyle(R.id.yourResourceId)).check(isDisplayed());