Page 1 of 1

So erhalten Sie von Textview und seiner Farbe, um einen Unit -Test zu schreiben

Posted: 22 Mar 2025, 03:00
by Anonymous
private void createStringEndingInRedColor(TextView tv, String word1, String word2) {
Spannable word = new SpannableString(word1);
tv.setText(word);

Spannable wordTwo = new SpannableString(word2);

wordTwo.setSpan(new ForegroundColorSpan(mContext.getResources().getColor(Color.RED)), 0, wordTwo.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.append(wordTwo);
}
< /code>

Ich versuche, einen Unit -Test (mit Robolectric) für das TextView -Fernseher zu schreiben, um sicherzustellen, dass Wordtwo farbe. Ich habe jedoch nur einen Verweis auf TextView TV. Wie geht man zu einer solchen Aufgabe?